From b10d5c58aabf59a4ca956e863e89ac45b95fe515 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Mon, 27 Nov 2023 15:48:31 -0800 Subject: [PATCH 01/20] backend: Add linux as platform for tests (#7375) - Also fixed a leak in `test_FeedbackLoops` --- filament/backend/CMakeLists.txt | 44 +++++++++------ filament/backend/test/BackendTest.cpp | 4 +- filament/backend/test/PlatformRunner.h | 3 ++ filament/backend/test/linux_runner.cpp | 56 ++++++++++++++++++++ filament/backend/test/mac_runner.mm | 2 +- filament/backend/test/test_FeedbackLoops.cpp | 1 + 6 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 filament/backend/test/linux_runner.cpp diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt index e088618b7b8..0420162a411 100644 --- a/filament/backend/CMakeLists.txt +++ b/filament/backend/CMakeLists.txt @@ -397,8 +397,8 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/backend DESTINATION include) # ================================================================================================== option(INSTALL_BACKEND_TEST "Install the backend test library so it can be consumed on iOS" OFF) -if (APPLE) - add_library(backend_test STATIC +if (APPLE OR LINUX) + set(BACKEND_TEST_SRC test/BackendTest.cpp test/ShaderGenerator.cpp test/TrianglePrimitive.cpp @@ -410,19 +410,26 @@ if (APPLE) test/test_BufferUpdates.cpp test/test_MRT.cpp test/test_LoadImage.cpp - test/test_RenderExternalImage.cpp test/test_StencilBuffer.cpp test/test_Scissor.cpp test/test_MipLevels.cpp - ) - - target_link_libraries(backend_test PRIVATE + ) + set(BACKEND_TEST_LIBS backend getopt gtest + imageio filamat SPIRV spirv-cross-glsl) +endif() + +if (APPLE) + # TODO: we should expand this test to Linux and other platforms. + list(APPEND BACKEND_TEST_SRC + test/test_RenderExternalImage.cpp) + add_library(backend_test STATIC ${BACKEND_TEST_SRC}) + target_link_libraries(backend_test PRIVATE ${BACKEND_TEST_LIBS}) set(BACKEND_TEST_DEPS OGLCompiler @@ -436,12 +443,11 @@ if (APPLE) glslang spirv-cross-core spirv-cross-glsl - spirv-cross-msl - ) + spirv-cross-msl) if (NOT IOS) target_link_libraries(backend_test PRIVATE image imageio) - list(APPEND BACKEND_TEST_DEPS image imageio) + list(APPEND BACKEND_TEST_DEPS image) endif() set(BACKEND_TEST_COMBINED_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libbackendtest_combined.a") @@ -455,15 +461,21 @@ if (APPLE) endif() set_target_properties(backend_test PROPERTIES FOLDER Tests) + + if (APPLE AND NOT IOS) + add_executable(backend_test_mac test/mac_runner.mm) + target_link_libraries(backend_test_mac PRIVATE "-framework Metal -framework AppKit -framework QuartzCore") + # Because each test case is a separate file, the -force_load flag is necessary to prevent the + # linker from removing "unused" symbols. + target_link_libraries(backend_test_mac PRIVATE -force_load backend_test) + set_target_properties(backend_test_mac PROPERTIES FOLDER Tests) + endif() endif() -if (APPLE AND NOT IOS) - add_executable(backend_test_mac test/mac_runner.mm) - target_link_libraries(backend_test_mac PRIVATE "-framework Metal -framework AppKit -framework QuartzCore") - # Because each test case is a separate file, the -force_load flag is necessary to prevent the - # linker from removing "unused" symbols. - target_link_libraries(backend_test_mac PRIVATE -force_load backend_test) - set_target_properties(backend_test_mac PROPERTIES FOLDER Tests) +if (LINUX) + add_executable(backend_test_linux test/linux_runner.cpp ${BACKEND_TEST_SRC}) + target_link_libraries(backend_test_linux PRIVATE ${BACKEND_TEST_LIBS}) + set_target_properties(backend_test_linux PROPERTIES FOLDER Tests) endif() # ================================================================================================== diff --git a/filament/backend/test/BackendTest.cpp b/filament/backend/test/BackendTest.cpp index 2cb5f75b95e..4a120b20ea2 100644 --- a/filament/backend/test/BackendTest.cpp +++ b/filament/backend/test/BackendTest.cpp @@ -93,6 +93,9 @@ void BackendTest::flushAndWait() { Handle BackendTest::createSwapChain() { const NativeView& view = getNativeView(); + if (!view.ptr) { + return getDriverApi().createSwapChainHeadless(view.width, view.height, 0); + } return getDriverApi().createSwapChain(view.ptr, 0); } @@ -212,4 +215,3 @@ int runTests() { } } // namespace test - diff --git a/filament/backend/test/PlatformRunner.h b/filament/backend/test/PlatformRunner.h index 7c4204b6d1d..0e0d30075ce 100644 --- a/filament/backend/test/PlatformRunner.h +++ b/filament/backend/test/PlatformRunner.h @@ -22,6 +22,9 @@ namespace test { +constexpr uint32_t const WINDOW_WIDTH = 512; +constexpr uint32_t const WINDOW_HEIGHT = 512; + // To avoid a dependency on filabridge, the Backend enum is replicated here. enum class Backend : uint8_t { OPENGL = 1, diff --git a/filament/backend/test/linux_runner.cpp b/filament/backend/test/linux_runner.cpp new file mode 100644 index 00000000000..f93715ef38f --- /dev/null +++ b/filament/backend/test/linux_runner.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "BackendTest.h" +#include "PlatformRunner.h" + +#include +#include + +namespace test { + +test::NativeView getNativeView() { + return { + .ptr = nullptr, + .width = WINDOW_WIDTH, + .height = WINDOW_HEIGHT, + }; +} + +}// namespace test + +namespace { + +std::array const VALID_BACKENDS{ + test::Backend::OPENGL, + test::Backend::VULKAN, +}; + +}// namespace + +int main(int argc, char* argv[]) { + auto backend = test::parseArgumentsForBackend(argc, argv); + + if (!std::any_of(VALID_BACKENDS.begin(), VALID_BACKENDS.end(), + [backend](test::Backend validBackend) { return backend == validBackend; })) { + std::cerr << "Specified an invalid backend. Only GL and Vulkan are available" << std::endl; + return 1; + } + + test::initTests(backend, false, argc, argv); + return test::runTests(); +} diff --git a/filament/backend/test/mac_runner.mm b/filament/backend/test/mac_runner.mm index 003eb853579..99205e2e7b6 100644 --- a/filament/backend/test/mac_runner.mm +++ b/filament/backend/test/mac_runner.mm @@ -58,7 +58,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { } - (NSView*)createView { - NSRect frame = NSMakeRect(0, 0, 512, 512); + NSRect frame = NSMakeRect(0, 0, test::WINDOW_WIDTH, test::WINDOW_HEIGHT); NSWindow* window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered diff --git a/filament/backend/test/test_FeedbackLoops.cpp b/filament/backend/test/test_FeedbackLoops.cpp index 871aad05f42..eba8b2be2ae 100644 --- a/filament/backend/test/test_FeedbackLoops.cpp +++ b/filament/backend/test/test_FeedbackLoops.cpp @@ -112,6 +112,7 @@ static void dumpScreenshot(DriverApi& dapi, Handle rt) { std::ofstream pngstrm("feedback.png", std::ios::binary | std::ios::trunc); ImageEncoder::encode(pngstrm, ImageEncoder::Format::PNG, image, "", "feedback.png"); #endif + free(buffer); }; PixelBufferDescriptor pb(buffer, size, PixelDataFormat::RGBA, PixelDataType::UBYTE, cb); dapi.readPixels(rt, 0, 0, kTexWidth, kTexHeight, std::move(pb)); From b066678a37605f1178cfac6c8c6937bba2647fe3 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Mon, 27 Nov 2023 16:54:49 -0800 Subject: [PATCH 02/20] matdbg: fix backend selection --- libs/matdbg/web/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/matdbg/web/app.js b/libs/matdbg/web/app.js index a77b04940a7..4a7c7df4e44 100644 --- a/libs/matdbg/web/app.js +++ b/libs/matdbg/web/app.js @@ -75,7 +75,7 @@ window.MonacoEnvironment = { }; const _validDict = (obj) => { - return obj && Object.keys(obj) > 0; + return obj && Object.keys(obj).length > 0; } const _isMatInfoMode = (database) => { From 9b67d80961b5f0463d4cc67f1be7d58291755ce7 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Tue, 28 Nov 2023 10:23:31 -0800 Subject: [PATCH 03/20] Add intermediate.h include to builtinResource.h (#7388) --- libs/filamat/src/sca/builtinResource.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/filamat/src/sca/builtinResource.h b/libs/filamat/src/sca/builtinResource.h index 53ef69ccc4c..d58f2a9d59a 100644 --- a/libs/filamat/src/sca/builtinResource.h +++ b/libs/filamat/src/sca/builtinResource.h @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "glslang/Include/intermediate.h" + const TBuiltInResource DefaultTBuiltInResource = { /* .MaxLights = */ 32, /* .MaxClipPlanes = */ 6, From e7c67d1adb45182a0b7e765a7d90564c26640da9 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 27 Nov 2023 14:42:11 -0800 Subject: [PATCH 04/20] Fix a possible NPE in UiHelper We were not unregistering the TextureView or SurfaceHolder callbacks on detach, so they could fire and access an null'ed RenderSurface FIXES=[308443790] --- .../android/filament/android/UiHelper.java | 329 +++++++++--------- 1 file changed, 167 insertions(+), 162 deletions(-) diff --git a/android/filament-android/src/main/java/com/google/android/filament/android/UiHelper.java b/android/filament-android/src/main/java/com/google/android/filament/android/UiHelper.java index 9184376702e..27ad007e886 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/android/UiHelper.java +++ b/android/filament-android/src/main/java/com/google/android/filament/android/UiHelper.java @@ -182,28 +182,85 @@ private interface RenderSurface { void detach(); } - private static class SurfaceViewHandler implements RenderSurface { - private final SurfaceView mSurfaceView; + private class SurfaceViewHandler implements RenderSurface, SurfaceHolder.Callback { + @NonNull private final SurfaceView mSurfaceView; - SurfaceViewHandler(SurfaceView surface) { - mSurfaceView = surface; + SurfaceViewHandler(@NonNull SurfaceView surfaceView) { + mSurfaceView = surfaceView; + + @NonNull SurfaceHolder holder = surfaceView.getHolder(); + holder.addCallback(this); + + if (mDesiredWidth > 0 && mDesiredHeight > 0) { + holder.setFixedSize(mDesiredWidth, mDesiredHeight); + } + + // in case the SurfaceView's surface already existed + final Surface surface = holder.getSurface(); + if (surface != null && surface.isValid()) { + surfaceCreated(holder); + // there is no way to retrieve the actual PixelFormat, since it is not used + // in the callback, we can use whatever we want. + surfaceChanged(holder, PixelFormat.RGBA_8888, + holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height()); + } } @Override public void resize(int width, int height) { - mSurfaceView.getHolder().setFixedSize(width, height); + @NonNull SurfaceHolder holder = mSurfaceView.getHolder(); + holder.setFixedSize(width, height); } @Override public void detach() { + @NonNull SurfaceHolder holder = mSurfaceView.getHolder(); + holder.removeCallback(this); + } + + @Override + public void surfaceCreated(@NonNull SurfaceHolder holder) { + if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()"); + createSwapChain(holder.getSurface()); + } + + @Override + public void surfaceChanged( + @NonNull SurfaceHolder holder, int format, int width, int height) { + // Note: this is always called at least once after surfaceCreated() + if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")"); + if (mRenderCallback != null) { + mRenderCallback.onResized(width, height); + } + } + + @Override + public void surfaceDestroyed(@NonNull SurfaceHolder holder) { + if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()"); + destroySwapChain(); } } - private static class SurfaceHolderHandler implements RenderSurface { + private class SurfaceHolderHandler implements RenderSurface, SurfaceHolder.Callback { private final SurfaceHolder mSurfaceHolder; - SurfaceHolderHandler(SurfaceHolder surface) { - mSurfaceHolder = surface; + SurfaceHolderHandler(@NonNull SurfaceHolder holder) { + mSurfaceHolder = holder; + holder.addCallback(this); + + if (mDesiredWidth > 0 && mDesiredHeight > 0) { + holder.setFixedSize(mDesiredWidth, mDesiredHeight); + } + + // in case the SurfaceHolder's surface already existed + final Surface surface = holder.getSurface(); + if (surface != null && surface.isValid()) { + surfaceCreated(holder); + // there is no way to retrieve the actual PixelFormat, since it is not used + // in the callback, we can use whatever we want. + surfaceChanged(holder, PixelFormat.RGBA_8888, + holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height()); + } } @Override @@ -213,19 +270,55 @@ public void resize(int width, int height) { @Override public void detach() { + mSurfaceHolder.removeCallback(this); + } + + @Override + public void surfaceCreated(@NonNull SurfaceHolder holder) { + if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()"); + createSwapChain(holder.getSurface()); + } + + @Override + public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) { + // Note: this is always called at least once after surfaceCreated() + if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")"); + if (mRenderCallback != null) { + mRenderCallback.onResized(width, height); + } + } + + @Override + public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) { + if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()"); + destroySwapChain(); } } - private class TextureViewHandler implements RenderSurface { + private class TextureViewHandler implements RenderSurface, TextureView.SurfaceTextureListener { private final TextureView mTextureView; private Surface mSurface; - TextureViewHandler(TextureView surface) { mTextureView = surface; } + TextureViewHandler(@NonNull TextureView view) { + mTextureView = view; + mTextureView.setSurfaceTextureListener(this); + // in case the View's SurfaceTexture already existed + if (view.isAvailable()) { + SurfaceTexture surfaceTexture = view.getSurfaceTexture(); + if (surfaceTexture != null) { + this.onSurfaceTextureAvailable(surfaceTexture, + mDesiredWidth, mDesiredHeight); + } + } + } @Override public void resize(int width, int height) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { - mTextureView.getSurfaceTexture().setDefaultBufferSize(width, height); + final SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture(); + if (surfaceTexture != null) { + surfaceTexture.setDefaultBufferSize(width, height); + } } if (mRenderCallback != null) { // the call above won't cause TextureView.onSurfaceTextureSizeChanged() @@ -235,10 +328,69 @@ public void resize(int width, int height) { @Override public void detach() { + mTextureView.setSurfaceTextureListener(null); setSurface(null); } - void setSurface(Surface surface) { + + @Override + public void onSurfaceTextureAvailable( + @NonNull SurfaceTexture surfaceTexture, int width, int height) { + if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureAvailable()"); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { + if (mDesiredWidth > 0 && mDesiredHeight > 0) { + surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight); + } + } + + final Surface surface = new Surface(surfaceTexture); + setSurface(surface); + createSwapChain(surface); + + if (mRenderCallback != null) { + // Call this the first time because onSurfaceTextureSizeChanged() + // isn't called at initialization time + mRenderCallback.onResized(width, height); + } + } + + @Override + public void onSurfaceTextureSizeChanged( + @NonNull SurfaceTexture surfaceTexture, int width, int height) { + if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureSizeChanged()"); + if (mRenderCallback != null) { + if (mDesiredWidth > 0 && mDesiredHeight > 0) { + surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight); + mRenderCallback.onResized(mDesiredWidth, mDesiredHeight); + } else { + mRenderCallback.onResized(width, height); + } + // We must recreate the SwapChain to guarantee that it sees the new size. + // More precisely, for an EGL client, the EGLSurface must be recreated. For + // a Vulkan client, the SwapChain must be recreated. Calling + // onNativeWindowChanged() will accomplish that. + // This requirement comes from SurfaceTexture.setDefaultBufferSize() + // documentation. + final Surface surface = getSurface(); + if (surface != null) { + mRenderCallback.onNativeWindowChanged(surface); + } + } + } + + @Override + public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) { + if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureDestroyed()"); + destroySwapChain(); + return true; + } + + @Override + public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) { } + + + private void setSurface(@Nullable Surface surface) { if (surface == null) { if (mSurface != null) { mSurface.release(); @@ -247,7 +399,7 @@ void setSurface(Surface surface) { mSurface = surface; } - public Surface getSurface() { + private Surface getSurface() { return mSurface; } } @@ -402,48 +554,8 @@ public void attachTo(@NonNull SurfaceView view) { view.setZOrderOnTop(translucent); } - int format = isOpaque() ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT; - view.getHolder().setFormat(format); - + view.getHolder().setFormat(isOpaque() ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT); mRenderSurface = new SurfaceViewHandler(view); - - final SurfaceHolder.Callback callback = new SurfaceHolder.Callback() { - @Override - public void surfaceCreated(@NonNull SurfaceHolder holder) { - if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()"); - createSwapChain(holder.getSurface()); - } - - @Override - public void surfaceChanged( - @NonNull SurfaceHolder holder, int format, int width, int height) { - // Note: this is always called at least once after surfaceCreated() - if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")"); - if (mRenderCallback != null) { - mRenderCallback.onResized(width, height); - } - } - - @Override - public void surfaceDestroyed(@NonNull SurfaceHolder holder) { - if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()"); - destroySwapChain(); - } - }; - - SurfaceHolder holder = view.getHolder(); - holder.addCallback(callback); - if (mDesiredWidth > 0 && mDesiredHeight > 0) { - holder.setFixedSize(mDesiredWidth, mDesiredHeight); - } - - // in case the SurfaceView's surface already existed - final Surface surface = holder.getSurface(); - if (surface != null && surface.isValid()) { - callback.surfaceCreated(holder); - callback.surfaceChanged(holder, format, - holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height()); - } } } @@ -455,76 +567,7 @@ public void surfaceDestroyed(@NonNull SurfaceHolder holder) { public void attachTo(@NonNull TextureView view) { if (attach(view)) { view.setOpaque(isOpaque()); - mRenderSurface = new TextureViewHandler(view); - - TextureView.SurfaceTextureListener listener = new TextureView.SurfaceTextureListener() { - @Override - public void onSurfaceTextureAvailable( - @NonNull SurfaceTexture surfaceTexture, int width, int height) { - if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureAvailable()"); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { - if (mDesiredWidth > 0 && mDesiredHeight > 0) { - surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight); - } - } - - Surface surface = new Surface(surfaceTexture); - TextureViewHandler textureViewHandler = (TextureViewHandler) mRenderSurface; - textureViewHandler.setSurface(surface); - - createSwapChain(surface); - - if (mRenderCallback != null) { - // Call this the first time because onSurfaceTextureSizeChanged() - // isn't called at initialization time - mRenderCallback.onResized(width, height); - } - } - - @Override - public void onSurfaceTextureSizeChanged( - @NonNull SurfaceTexture surfaceTexture, int width, int height) { - if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureSizeChanged()"); - if (mRenderCallback != null) { - if (mDesiredWidth > 0 && mDesiredHeight > 0) { - surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight); - mRenderCallback.onResized(mDesiredWidth, mDesiredHeight); - } else { - mRenderCallback.onResized(width, height); - } - // We must recreate the SwapChain to guarantee that it sees the new size. - // More precisely, for an EGL client, the EGLSurface must be recreated. For - // a Vulkan client, the SwapChain must be recreated. Calling - // onNativeWindowChanged() will accomplish that. - // This requirement comes from SurfaceTexture.setDefaultBufferSize() - // documentation. - TextureViewHandler textureViewHandler = (TextureViewHandler) mRenderSurface; - mRenderCallback.onNativeWindowChanged(textureViewHandler.getSurface()); - } - } - - @Override - public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) { - if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureDestroyed()"); - destroySwapChain(); - return true; - } - - @Override - public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) { } - }; - - view.setSurfaceTextureListener(listener); - - // in case the View's SurfaceTexture already existed - if (view.isAvailable()) { - SurfaceTexture surfaceTexture = view.getSurfaceTexture(); - if (surfaceTexture != null) { - listener.onSurfaceTextureAvailable(surfaceTexture, mDesiredWidth, mDesiredHeight); - } - } } } @@ -535,46 +578,8 @@ public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) { } */ public void attachTo(@NonNull SurfaceHolder holder) { if (attach(holder)) { - int format = isOpaque() ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT; - holder.setFormat(format); - + holder.setFormat(isOpaque() ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT); mRenderSurface = new SurfaceHolderHandler(holder); - - final SurfaceHolder.Callback callback = new SurfaceHolder.Callback() { - @Override - public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) { - if (LOGGING) Log.d(LOG_TAG, "surfaceCreated()"); - createSwapChain(holder.getSurface()); - } - - @Override - public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) { - // Note: this is always called at least once after surfaceCreated() - if (LOGGING) Log.d(LOG_TAG, "surfaceChanged(" + width + ", " + height + ")"); - if (mRenderCallback != null) { - mRenderCallback.onResized(width, height); - } - } - - @Override - public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) { - if (LOGGING) Log.d(LOG_TAG, "surfaceDestroyed()"); - destroySwapChain(); - } - }; - - holder.addCallback(callback); - if (mDesiredWidth > 0 && mDesiredHeight > 0) { - holder.setFixedSize(mDesiredWidth, mDesiredHeight); - } - - // in case the SurfaceHolder's surface already existed - final Surface surface = holder.getSurface(); - if (surface != null && surface.isValid()) { - callback.surfaceCreated(holder); - callback.surfaceChanged(holder, format, - holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height()); - } } } From 1be3e13427cdad8ec807f5d77ca0fc167bc7a397 Mon Sep 17 00:00:00 2001 From: Rene Sepulveda Date: Mon, 27 Nov 2023 23:06:01 -0500 Subject: [PATCH 05/20] Add namespace qualifiers to satisfy gcc (-fpermissive) --- filament/include/filament/Material.h | 10 +++---- filament/include/filament/View.h | 40 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/filament/include/filament/Material.h b/filament/include/filament/Material.h index 3b0ff0f30e8..8e441958bb2 100644 --- a/filament/include/filament/Material.h +++ b/filament/include/filament/Material.h @@ -50,11 +50,11 @@ class UTILS_PUBLIC Material : public FilamentAPI { struct BuilderDetails; public: - using BlendingMode = BlendingMode; - using Shading = Shading; - using Interpolation = Interpolation; - using VertexDomain = VertexDomain; - using TransparencyMode = TransparencyMode; + using BlendingMode = filament::BlendingMode; + using Shading = filament::Shading; + using Interpolation = filament::Interpolation; + using VertexDomain = filament::VertexDomain; + using TransparencyMode = filament::TransparencyMode; using ParameterType = backend::UniformType; using Precision = backend::Precision; diff --git a/filament/include/filament/View.h b/filament/include/filament/View.h index 8832e054cf2..818ef2bd72a 100644 --- a/filament/include/filament/View.h +++ b/filament/include/filament/View.h @@ -66,26 +66,26 @@ class Viewport; */ class UTILS_PUBLIC View : public FilamentAPI { public: - using QualityLevel = QualityLevel; - using BlendMode = BlendMode; - using AntiAliasing = AntiAliasing; - using Dithering = Dithering; - using ShadowType = ShadowType; - - using DynamicResolutionOptions = DynamicResolutionOptions; - using BloomOptions = BloomOptions; - using FogOptions = FogOptions; - using DepthOfFieldOptions = DepthOfFieldOptions; - using VignetteOptions = VignetteOptions; - using RenderQuality = RenderQuality; - using AmbientOcclusionOptions = AmbientOcclusionOptions; - using TemporalAntiAliasingOptions = TemporalAntiAliasingOptions; - using MultiSampleAntiAliasingOptions = MultiSampleAntiAliasingOptions; - using VsmShadowOptions = VsmShadowOptions; - using SoftShadowOptions = SoftShadowOptions; - using ScreenSpaceReflectionsOptions = ScreenSpaceReflectionsOptions; - using GuardBandOptions = GuardBandOptions; - using StereoscopicOptions = StereoscopicOptions; + using QualityLevel = filament::QualityLevel; + using BlendMode = filament::BlendMode; + using AntiAliasing = filament::AntiAliasing; + using Dithering = filament::Dithering; + using ShadowType = filament::ShadowType; + + using DynamicResolutionOptions = filament::DynamicResolutionOptions; + using BloomOptions = filament::BloomOptions; + using FogOptions = filament::FogOptions; + using DepthOfFieldOptions = filament::DepthOfFieldOptions; + using VignetteOptions = filament::VignetteOptions; + using RenderQuality = filament::RenderQuality; + using AmbientOcclusionOptions = filament::AmbientOcclusionOptions; + using TemporalAntiAliasingOptions = filament::TemporalAntiAliasingOptions; + using MultiSampleAntiAliasingOptions = filament::MultiSampleAntiAliasingOptions; + using VsmShadowOptions = filament::VsmShadowOptions; + using SoftShadowOptions = filament::SoftShadowOptions; + using ScreenSpaceReflectionsOptions = filament::ScreenSpaceReflectionsOptions; + using GuardBandOptions = filament::GuardBandOptions; + using StereoscopicOptions = filament::StereoscopicOptions; /** * Sets the View's name. Only useful for debugging. From 06bae26e1b6b4b28b9fc1d95ac75700add1132fc Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 29 Nov 2023 09:39:35 -0800 Subject: [PATCH 06/20] better handle invalid programs in release builds (#7389) * better handle invalid programs in release builds Until now invalid program would basically be undefined behavior, which in practice was a crash via a null pointer dereference. With this change, invalid programs cause drawing ops to become no-ops. Additionally fixed an unsynchronized access of a the variable containing the program id. I don't think it would have caused issues though. FIXES=[311775564] Co-authored-by: Powei Feng --- filament/backend/src/opengl/OpenGLDriver.cpp | 38 ++++++++++--------- filament/backend/src/opengl/OpenGLDriver.h | 2 +- filament/backend/src/opengl/OpenGLProgram.cpp | 2 +- filament/backend/src/opengl/OpenGLProgram.h | 2 +- .../src/opengl/ShaderCompilerService.cpp | 7 +--- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/filament/backend/src/opengl/OpenGLDriver.cpp b/filament/backend/src/opengl/OpenGLDriver.cpp index 1c49dcc0ecf..83b20156f32 100644 --- a/filament/backend/src/opengl/OpenGLDriver.cpp +++ b/filament/backend/src/opengl/OpenGLDriver.cpp @@ -262,7 +262,12 @@ void OpenGLDriver::bindTexture(GLuint unit, GLTexture const* t) noexcept { mContext.bindTexture(unit, t->gl.target, t->gl.id, t->gl.targetIndex); } -void OpenGLDriver::useProgram(OpenGLProgram* p) noexcept { +bool OpenGLDriver::useProgram(OpenGLProgram* p) noexcept { + if (UTILS_UNLIKELY(!p->isValid())) { + // If the program is not valid, we can't call use(). + return false; + } + // set-up textures and samplers in the proper TMUs (as specified in setSamplers) p->use(this, mContext); @@ -277,6 +282,7 @@ void OpenGLDriver::useProgram(OpenGLProgram* p) noexcept { // when mPlatform.isSRGBSwapChainSupported() is false (no need to check though). p->setRec709ColorSpace(mRec709OutputColorspace); } + return true; } @@ -3531,18 +3537,17 @@ void OpenGLDriver::draw(PipelineState state, Handle rph, uint DEBUG_MARKER() auto& gl = mContext; - OpenGLProgram* p = handle_cast(state.program); + OpenGLProgram* const p = handle_cast(state.program); - // If the material debugger is enabled, avoid fatal (or cascading) errors and that can occur - // during the draw call when the program is invalid. The shader compile error has already been - // dumped to the console at this point, so it's fine to simply return early. - if (FILAMENT_ENABLE_MATDBG && UTILS_UNLIKELY(!p->isValid())) { + bool const success = useProgram(p); + if (UTILS_UNLIKELY(!success)) { + // Avoid fatal (or cascading) errors that can occur during the draw call when the program + // is invalid. The shader compile error has already been dumped to the console at this + // point, so it's fine to simply return early. return; } - useProgram(p); - - GLRenderPrimitive* rp = handle_cast(rph); + GLRenderPrimitive* const rp = handle_cast(rph); // Gracefully do nothing if the render primitive has not been set up. VertexBufferHandle vb = rp->gl.vertexBufferWithObjects; @@ -3553,7 +3558,7 @@ void OpenGLDriver::draw(PipelineState state, Handle rph, uint gl.bindVertexArray(&rp->gl); // If necessary, mutate the bindings in the VAO. - const GLVertexBuffer* glvb = handle_cast(vb); + GLVertexBuffer const* const glvb = handle_cast(vb); if (UTILS_UNLIKELY(rp->gl.vertexBufferVersion != glvb->bufferObjectsVersion)) { updateVertexArrayObject(rp, glvb); } @@ -3587,17 +3592,16 @@ void OpenGLDriver::draw(PipelineState state, Handle rph, uint void OpenGLDriver::dispatchCompute(Handle program, math::uint3 workGroupCount) { getShaderCompilerService().tick(); - OpenGLProgram* p = handle_cast(program); + OpenGLProgram* const p = handle_cast(program); - // If the material debugger is enabled, avoid fatal (or cascading) errors and that can occur - // during the draw call when the program is invalid. The shader compile error has already been - // dumped to the console at this point, so it's fine to simply return early. - if (FILAMENT_ENABLE_MATDBG && UTILS_UNLIKELY(!p->isValid())) { + bool const success = useProgram(p); + if (UTILS_UNLIKELY(!success)) { + // Avoid fatal (or cascading) errors that can occur during the draw call when the program + // is invalid. The shader compile error has already been dumped to the console at this + // point, so it's fine to simply return early. return; } - useProgram(p); - #if defined(BACKEND_OPENGL_LEVEL_GLES31) #if defined(__ANDROID__) diff --git a/filament/backend/src/opengl/OpenGLDriver.h b/filament/backend/src/opengl/OpenGLDriver.h index f3c87c61768..04e003fb3da 100644 --- a/filament/backend/src/opengl/OpenGLDriver.h +++ b/filament/backend/src/opengl/OpenGLDriver.h @@ -318,7 +318,7 @@ class OpenGLDriver final : public DriverBase { void bindTexture(GLuint unit, GLTexture const* t) noexcept; void bindSampler(GLuint unit, GLuint sampler) noexcept; - inline void useProgram(OpenGLProgram* p) noexcept; + inline bool useProgram(OpenGLProgram* p) noexcept; enum class ResolveAction { LOAD, STORE }; void resolvePass(ResolveAction action, GLRenderTarget const* rt, diff --git a/filament/backend/src/opengl/OpenGLProgram.cpp b/filament/backend/src/opengl/OpenGLProgram.cpp index 69412e1aea1..aef088f60cf 100644 --- a/filament/backend/src/opengl/OpenGLProgram.cpp +++ b/filament/backend/src/opengl/OpenGLProgram.cpp @@ -129,7 +129,7 @@ void OpenGLProgram::initializeProgramState(OpenGLContext& context, GLuint progra #endif { // ES2 initialization of (fake) UBOs - UniformsRecord* const uniformsRecords = new UniformsRecord[Program::UNIFORM_BINDING_COUNT]; + UniformsRecord* const uniformsRecords = new(std::nothrow) UniformsRecord[Program::UNIFORM_BINDING_COUNT]; UTILS_NOUNROLL for (GLuint binding = 0, n = Program::UNIFORM_BINDING_COUNT; binding < n; binding++) { Program::UniformInfo& uniforms = lazyInitializationData.bindingUniformInfo[binding]; diff --git a/filament/backend/src/opengl/OpenGLProgram.h b/filament/backend/src/opengl/OpenGLProgram.h index ddee9496690..5d74fdc827d 100644 --- a/filament/backend/src/opengl/OpenGLProgram.h +++ b/filament/backend/src/opengl/OpenGLProgram.h @@ -59,7 +59,7 @@ class OpenGLProgram : public HwProgram { // - the content of any bound sampler buffer has changed // ... since last time we used this program - // turns out the former might be relatively cheap to check, the later requires + // Turns out the former might be relatively cheap to check, the latter requires // a bit less. Compared to what updateSamplers() actually does, which is // pretty little, I'm not sure if we'll get ahead. diff --git a/filament/backend/src/opengl/ShaderCompilerService.cpp b/filament/backend/src/opengl/ShaderCompilerService.cpp index 9ab30a9bf10..e816b0161d9 100644 --- a/filament/backend/src/opengl/ShaderCompilerService.cpp +++ b/filament/backend/src/opengl/ShaderCompilerService.cpp @@ -22,7 +22,6 @@ #include -#include #include #include @@ -254,8 +253,6 @@ ShaderCompilerService::program_token_t ShaderCompilerService::createProgram( glGetProgramiv(glProgram, GL_LINK_STATUS, &status); programData.program = glProgram; - token->gl.program = programData.program; - // we don't need to check for success here, it'll be done on the // main thread side. token->set(programData); @@ -337,12 +334,12 @@ GLuint ShaderCompilerService::getProgram(ShaderCompilerService::program_token_t& return program; } -/* static*/ void ShaderCompilerService::terminate(program_token_t& token) { +void ShaderCompilerService::terminate(program_token_t& token) { assert_invariant(token); token->canceled = true; - bool canceled = token->compiler.cancelTickOp(token); + bool const canceled = token->compiler.cancelTickOp(token); if (token->compiler.mShaderCompilerThreadCount) { auto job = token->compiler.mCompilerThreadPool.dequeue(token); From b007e9137eb029e256675eceb5fd52e6b873cecd Mon Sep 17 00:00:00 2001 From: Eliza Velasquez Date: Wed, 29 Nov 2023 16:50:34 -0800 Subject: [PATCH 07/20] Fix ESSL 1.0 external samplers matc was re-introducing the incorrect extension for external samplers in ESSL 1.0 code after spirv optimizations. --- NEW_RELEASE_NOTES.md | 2 ++ libs/filamat/src/MaterialBuilder.cpp | 3 ++- libs/filamat/src/shaders/CodeGenerator.cpp | 7 +++++-- libs/filamat/src/shaders/CodeGenerator.h | 3 ++- libs/filamat/src/shaders/ShaderGenerator.cpp | 7 ++++--- libs/filamat/src/shaders/ShaderGenerator.h | 1 + 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index 4a1a9c7fa7e..59d7dab31c6 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -7,3 +7,5 @@ for next branch cut* header. appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut + +- matc: Fix ESSL 1.0 codegen when using external samplers [⚠️ **Recompile materials**] diff --git a/libs/filamat/src/MaterialBuilder.cpp b/libs/filamat/src/MaterialBuilder.cpp index a95bb077819..050dd3ebde6 100644 --- a/libs/filamat/src/MaterialBuilder.cpp +++ b/libs/filamat/src/MaterialBuilder.cpp @@ -912,7 +912,8 @@ bool MaterialBuilder::generateShaders(JobSystem& jobSystem, const std::vector= FeatureLevel::FEATURE_LEVEL_1) + ? "#extension GL_OES_EGL_image_external_essl3 : require\n\n" + : "#extension GL_OES_EGL_image_external : require\n\n"; + shader.insert(index, extensionLine); } } diff --git a/libs/filamat/src/shaders/CodeGenerator.h b/libs/filamat/src/shaders/CodeGenerator.h index 00fbb3ce824..4467ccc7657 100644 --- a/libs/filamat/src/shaders/CodeGenerator.h +++ b/libs/filamat/src/shaders/CodeGenerator.h @@ -161,7 +161,8 @@ class UTILS_PRIVATE CodeGenerator { static utils::io::sstream& generateParameters(utils::io::sstream& out, ShaderStage type); static void fixupExternalSamplers( - std::string& shader, filament::SamplerInterfaceBlock const& sib) noexcept; + std::string& shader, filament::SamplerInterfaceBlock const& sib, + FeatureLevel featureLevel) noexcept; // These constants must match the equivalent in MetalState.h. // These values represent the starting index for uniform, ssbo, and sampler group [[buffer(n)]] diff --git a/libs/filamat/src/shaders/ShaderGenerator.cpp b/libs/filamat/src/shaders/ShaderGenerator.cpp index 674452e997f..e1516be1436 100644 --- a/libs/filamat/src/shaders/ShaderGenerator.cpp +++ b/libs/filamat/src/shaders/ShaderGenerator.cpp @@ -342,12 +342,13 @@ ShaderGenerator::ShaderGenerator( } } -void ShaderGenerator::fixupExternalSamplers(ShaderModel sm, - std::string& shader, MaterialInfo const& material) noexcept { +void ShaderGenerator::fixupExternalSamplers(ShaderModel sm, std::string& shader, + MaterialBuilder::FeatureLevel featureLevel, + MaterialInfo const& material) noexcept { // External samplers are only supported on GL ES at the moment, we must // skip the fixup on desktop targets if (material.hasExternalSamplers && sm == ShaderModel::MOBILE) { - CodeGenerator::fixupExternalSamplers(shader, material.sib); + CodeGenerator::fixupExternalSamplers(shader, material.sib, featureLevel); } } diff --git a/libs/filamat/src/shaders/ShaderGenerator.h b/libs/filamat/src/shaders/ShaderGenerator.h index 99152d8f687..985fd63a017 100644 --- a/libs/filamat/src/shaders/ShaderGenerator.h +++ b/libs/filamat/src/shaders/ShaderGenerator.h @@ -75,6 +75,7 @@ class ShaderGenerator { * the optimizations have been applied. */ static void fixupExternalSamplers(filament::backend::ShaderModel sm, std::string& shader, + MaterialBuilder::FeatureLevel featureLevel, MaterialInfo const& material) noexcept; private: From 164d7507bbf7fd90972201ccf942d153b0712475 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Fri, 1 Dec 2023 11:00:53 -0800 Subject: [PATCH 08/20] Update MATERIAL_VERSION to 48 --- libs/filabridge/include/filament/MaterialEnums.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/filabridge/include/filament/MaterialEnums.h b/libs/filabridge/include/filament/MaterialEnums.h index 67cdd8620f9..6a74ac7e3a9 100644 --- a/libs/filabridge/include/filament/MaterialEnums.h +++ b/libs/filabridge/include/filament/MaterialEnums.h @@ -28,7 +28,7 @@ namespace filament { // update this when a new version of filament wouldn't work with older materials -static constexpr size_t MATERIAL_VERSION = 47; +static constexpr size_t MATERIAL_VERSION = 48; /** * Supported shading models From d9ee526a726d36f6345103bfc05b97dfa224608c Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 4 Dec 2023 16:43:35 -0800 Subject: [PATCH 09/20] fix jni Scene.getEntities we were using the version of ReleaseIntArrayElements that doesn't always keep changes to the array. --- android/filament-android/src/main/cpp/EntityManager.cpp | 2 +- android/filament-android/src/main/cpp/MaterialInstance.cpp | 2 +- android/filament-android/src/main/cpp/Scene.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/filament-android/src/main/cpp/EntityManager.cpp b/android/filament-android/src/main/cpp/EntityManager.cpp index 353dd0aa359..9348e2cca7d 100644 --- a/android/filament-android/src/main/cpp/EntityManager.cpp +++ b/android/filament-android/src/main/cpp/EntityManager.cpp @@ -38,7 +38,7 @@ Java_com_google_android_filament_EntityManager_nCreateArray(JNIEnv* env, jclass, // (which it is), but still. em->create((size_t) n, reinterpret_cast(entities)); - env->ReleaseIntArrayElements(entities_, entities, 0); + env->ReleaseIntArrayElements(entities_, entities, JNI_ABORT); } extern "C" JNIEXPORT jint JNICALL diff --git a/android/filament-android/src/main/cpp/MaterialInstance.cpp b/android/filament-android/src/main/cpp/MaterialInstance.cpp index c0b0bcb7168..c5c4ba78fbb 100644 --- a/android/filament-android/src/main/cpp/MaterialInstance.cpp +++ b/android/filament-android/src/main/cpp/MaterialInstance.cpp @@ -205,7 +205,7 @@ Java_com_google_android_filament_MaterialInstance_nSetIntParameterArray(JNIEnv * break; } - env->ReleaseIntArrayElements(v_, v, 0); + env->ReleaseIntArrayElements(v_, v, JNI_ABORT); env->ReleaseStringUTFChars(name_, name); } diff --git a/android/filament-android/src/main/cpp/Scene.cpp b/android/filament-android/src/main/cpp/Scene.cpp index 14b0b49a948..bfbc70d5e4c 100644 --- a/android/filament-android/src/main/cpp/Scene.cpp +++ b/android/filament-android/src/main/cpp/Scene.cpp @@ -114,6 +114,6 @@ Java_com_google_android_filament_Scene_nGetEntities(JNIEnv *env, jclass , out[i++] = (jint) entity.getId(); } }); - env->ReleaseIntArrayElements(outArray, (jint*) out, JNI_ABORT); + env->ReleaseIntArrayElements(outArray, (jint*) out, 0); return JNI_TRUE; } From f8057b9a5b8e3a31f7bcf8894534b1166252c368 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Tue, 5 Dec 2023 10:02:15 -0800 Subject: [PATCH 10/20] Add spirv-headers as a separate third_party repo (#7401) * Add spirv-headers as a separate third_party repo Previously, we pulled in spirv-headers as part of spirv-tools. We still keep this behavior but move the content of the repo to third_party. We introduce a script for updating spirv-tools, and update the patch file. The same script will also pull in a dependent spirv-headers. --- .../spirv-headers/.gitattributes | 0 .../external => }/spirv-headers/.gitignore | 0 .../external => }/spirv-headers/BUILD.bazel | 0 .../external => }/spirv-headers/BUILD.gn | 0 .../spirv-headers/CMakeLists.txt | 8 +- .../spirv-headers/CODE_OF_CONDUCT.md | 0 third_party/spirv-headers/FILAMENT_README.md | 5 ++ .../external => }/spirv-headers/LICENSE | 0 .../external => }/spirv-headers/README.md | 0 .../spirv-headers/SPIRV-Headers.pc.in | 0 .../external => }/spirv-headers/WORKSPACE | 0 .../spirv-headers/cmake/Config.cmake.in | 0 .../spirv-headers/example/CMakeLists.txt | 0 .../spirv-headers/example/example.cpp | 0 .../include/spirv/1.0/GLSL.std.450.h | 0 .../include/spirv/1.0/OpenCL.std.h | 0 .../1.0/extinst.glsl.std.450.grammar.json | 0 .../1.0/extinst.opencl.std.100.grammar.json | 0 .../include/spirv/1.0/spirv.core.grammar.json | 0 .../spirv-headers/include/spirv/1.0/spirv.cs | 0 .../spirv-headers/include/spirv/1.0/spirv.h | 0 .../spirv-headers/include/spirv/1.0/spirv.hpp | 0 .../include/spirv/1.0/spirv.hpp11 | 0 .../include/spirv/1.0/spirv.json | 0 .../spirv-headers/include/spirv/1.0/spirv.lua | 0 .../spirv-headers/include/spirv/1.0/spirv.py | 0 .../include/spirv/1.1/GLSL.std.450.h | 0 .../include/spirv/1.1/OpenCL.std.h | 0 .../1.1/extinst.glsl.std.450.grammar.json | 0 .../1.1/extinst.opencl.std.100.grammar.json | 0 .../include/spirv/1.1/spirv.core.grammar.json | 0 .../spirv-headers/include/spirv/1.1/spirv.cs | 0 .../spirv-headers/include/spirv/1.1/spirv.h | 0 .../spirv-headers/include/spirv/1.1/spirv.hpp | 0 .../include/spirv/1.1/spirv.hpp11 | 0 .../include/spirv/1.1/spirv.json | 0 .../spirv-headers/include/spirv/1.1/spirv.lua | 0 .../spirv-headers/include/spirv/1.1/spirv.py | 0 .../include/spirv/1.2/GLSL.std.450.h | 0 .../include/spirv/1.2/OpenCL.std.h | 0 .../1.2/extinst.glsl.std.450.grammar.json | 0 .../1.2/extinst.opencl.std.100.grammar.json | 0 .../include/spirv/1.2/spirv.core.grammar.json | 0 .../spirv-headers/include/spirv/1.2/spirv.cs | 0 .../spirv-headers/include/spirv/1.2/spirv.h | 0 .../spirv-headers/include/spirv/1.2/spirv.hpp | 0 .../include/spirv/1.2/spirv.hpp11 | 0 .../include/spirv/1.2/spirv.json | 0 .../spirv-headers/include/spirv/1.2/spirv.lua | 0 .../spirv-headers/include/spirv/1.2/spirv.py | 0 .../spirv-headers/include/spirv/spir-v.xml | 0 .../include/spirv/unified1/AMD_gcn_shader.h | 0 .../spirv/unified1/AMD_shader_ballot.h | 0 .../AMD_shader_explicit_vertex_parameter.h | 0 .../unified1/AMD_shader_trinary_minmax.h | 0 .../include/spirv/unified1/DebugInfo.h | 0 .../include/spirv/unified1/GLSL.std.450.h | 0 .../unified1/NonSemanticClspvReflection.h | 0 .../spirv/unified1/NonSemanticDebugPrintf.h | 0 .../unified1/NonSemanticShaderDebugInfo100.h | 0 .../include/spirv/unified1/OpenCL.std.h | 0 .../spirv/unified1/OpenCLDebugInfo100.h | 0 .../unified1/extinst.debuginfo.grammar.json | 0 .../extinst.glsl.std.450.grammar.json | 0 ...t.nonsemantic.clspvreflection.grammar.json | 0 ...tinst.nonsemantic.debugprintf.grammar.json | 0 ...semantic.shader.debuginfo.100.grammar.json | 0 .../extinst.opencl.debuginfo.100.grammar.json | 0 .../extinst.opencl.std.100.grammar.json | 0 .../extinst.spv-amd-gcn-shader.grammar.json | 0 ...extinst.spv-amd-shader-ballot.grammar.json | 0 ...der-explicit-vertex-parameter.grammar.json | 0 ...spv-amd-shader-trinary-minmax.grammar.json | 0 .../include/spirv/unified1/spirv.bf | 0 .../spirv/unified1/spirv.core.grammar.json | 0 .../include/spirv/unified1/spirv.cs | 0 .../include/spirv/unified1/spirv.h | 0 .../include/spirv/unified1/spirv.hpp | 0 .../include/spirv/unified1/spirv.hpp11 | 0 .../include/spirv/unified1/spirv.json | 0 .../include/spirv/unified1/spirv.lua | 0 .../include/spirv/unified1/spirv.py | 0 .../include/spirv/unified1/spv.d | 0 .../tools/buildHeaders/CMakeLists.txt | 0 .../bin/generate_language_headers.py | 0 .../buildHeaders/bin/makeExtinstHeaders.py | 0 .../tools/buildHeaders/bin/makeHeaders | 0 .../tools/buildHeaders/header.cpp | 0 .../spirv-headers/tools/buildHeaders/header.h | 0 .../tools/buildHeaders/jsonToSpirv.cpp | 0 .../tools/buildHeaders/jsonToSpirv.h | 0 .../spirv-headers/tools/buildHeaders/main.cpp | 0 third_party/spirv-tools/CMakeLists.txt | 6 +- third_party/spirv-tools/FILAMENT_README.md | 36 +++----- .../spirv-tools/external/CMakeLists.txt | 2 + .../.github/workflows/presubmit.yml | 37 -------- .../filament-specific-changes.patch | 90 ++++--------------- third_party/spirv-tools/filament-update.sh | 53 +++++++++++ 98 files changed, 98 insertions(+), 139 deletions(-) rename third_party/{spirv-tools/external => }/spirv-headers/.gitattributes (100%) rename third_party/{spirv-tools/external => }/spirv-headers/.gitignore (100%) rename third_party/{spirv-tools/external => }/spirv-headers/BUILD.bazel (100%) rename third_party/{spirv-tools/external => }/spirv-headers/BUILD.gn (100%) rename third_party/{spirv-tools/external => }/spirv-headers/CMakeLists.txt (95%) rename third_party/{spirv-tools/external => }/spirv-headers/CODE_OF_CONDUCT.md (100%) create mode 100644 third_party/spirv-headers/FILAMENT_README.md rename third_party/{spirv-tools/external => }/spirv-headers/LICENSE (100%) rename third_party/{spirv-tools/external => }/spirv-headers/README.md (100%) rename third_party/{spirv-tools/external => }/spirv-headers/SPIRV-Headers.pc.in (100%) rename third_party/{spirv-tools/external => }/spirv-headers/WORKSPACE (100%) rename third_party/{spirv-tools/external => }/spirv-headers/cmake/Config.cmake.in (100%) rename third_party/{spirv-tools/external => }/spirv-headers/example/CMakeLists.txt (100%) rename third_party/{spirv-tools/external => }/spirv-headers/example/example.cpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/GLSL.std.450.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/OpenCL.std.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/extinst.opencl.std.100.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.core.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.cs (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.hpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.hpp11 (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.lua (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.0/spirv.py (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/GLSL.std.450.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/OpenCL.std.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/extinst.glsl.std.450.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/extinst.opencl.std.100.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.core.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.cs (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.hpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.hpp11 (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.lua (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.1/spirv.py (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/GLSL.std.450.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/OpenCL.std.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/extinst.glsl.std.450.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/extinst.opencl.std.100.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.core.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.cs (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.hpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.hpp11 (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.lua (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/1.2/spirv.py (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/spir-v.xml (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/DebugInfo.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/GLSL.std.450.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/OpenCL.std.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugprintf.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.spv-amd-gcn-shader.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-ballot.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-trinary-minmax.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.bf (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.core.grammar.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.cs (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.hpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.hpp11 (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.json (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.lua (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spirv.py (100%) rename third_party/{spirv-tools/external => }/spirv-headers/include/spirv/unified1/spv.d (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/CMakeLists.txt (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/bin/makeHeaders (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/header.cpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/header.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/jsonToSpirv.h (100%) rename third_party/{spirv-tools/external => }/spirv-headers/tools/buildHeaders/main.cpp (100%) delete mode 100644 third_party/spirv-tools/external/spirv-headers/.github/workflows/presubmit.yml create mode 100644 third_party/spirv-tools/filament-update.sh diff --git a/third_party/spirv-tools/external/spirv-headers/.gitattributes b/third_party/spirv-headers/.gitattributes similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/.gitattributes rename to third_party/spirv-headers/.gitattributes diff --git a/third_party/spirv-tools/external/spirv-headers/.gitignore b/third_party/spirv-headers/.gitignore similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/.gitignore rename to third_party/spirv-headers/.gitignore diff --git a/third_party/spirv-tools/external/spirv-headers/BUILD.bazel b/third_party/spirv-headers/BUILD.bazel similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/BUILD.bazel rename to third_party/spirv-headers/BUILD.bazel diff --git a/third_party/spirv-tools/external/spirv-headers/BUILD.gn b/third_party/spirv-headers/BUILD.gn similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/BUILD.gn rename to third_party/spirv-headers/BUILD.gn diff --git a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt b/third_party/spirv-headers/CMakeLists.txt similarity index 95% rename from third_party/spirv-tools/external/spirv-headers/CMakeLists.txt rename to third_party/spirv-headers/CMakeLists.txt index 2b8bb5e5959..9cfba73af29 100644 --- a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt +++ b/third_party/spirv-headers/CMakeLists.txt @@ -28,7 +28,7 @@ # The SPIR-V headers from the SPIR-V Registry # https://www.khronos.org/registry/spir-v/ # -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.0) project(SPIRV-Headers VERSION 1.5.5) # There are two ways to use this project. @@ -44,9 +44,11 @@ project(SPIRV-Headers VERSION 1.5.5) # 2. cmake .. # 3. cmake --build . --target install -option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) +option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" + ${SPIRV_HEADERS_SKIP_EXAMPLES}) -option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) +option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" + ${SPIRV_HEADERS_SKIP_INSTALL}) if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-tools/external/spirv-headers/CODE_OF_CONDUCT.md b/third_party/spirv-headers/CODE_OF_CONDUCT.md similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/CODE_OF_CONDUCT.md rename to third_party/spirv-headers/CODE_OF_CONDUCT.md diff --git a/third_party/spirv-headers/FILAMENT_README.md b/third_party/spirv-headers/FILAMENT_README.md new file mode 100644 index 00000000000..c3eed55a2ef --- /dev/null +++ b/third_party/spirv-headers/FILAMENT_README.md @@ -0,0 +1,5 @@ +This project is pulled in as a dependency for spirv-tools. The Vulkan +backend also has a dependency on this project. This project should not +be updated directly, instead, please see +/third_party/spirv-tools/FILAMENT_README.md for instructions for +update. diff --git a/third_party/spirv-tools/external/spirv-headers/LICENSE b/third_party/spirv-headers/LICENSE similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/LICENSE rename to third_party/spirv-headers/LICENSE diff --git a/third_party/spirv-tools/external/spirv-headers/README.md b/third_party/spirv-headers/README.md similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/README.md rename to third_party/spirv-headers/README.md diff --git a/third_party/spirv-tools/external/spirv-headers/SPIRV-Headers.pc.in b/third_party/spirv-headers/SPIRV-Headers.pc.in similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/SPIRV-Headers.pc.in rename to third_party/spirv-headers/SPIRV-Headers.pc.in diff --git a/third_party/spirv-tools/external/spirv-headers/WORKSPACE b/third_party/spirv-headers/WORKSPACE similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/WORKSPACE rename to third_party/spirv-headers/WORKSPACE diff --git a/third_party/spirv-tools/external/spirv-headers/cmake/Config.cmake.in b/third_party/spirv-headers/cmake/Config.cmake.in similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/cmake/Config.cmake.in rename to third_party/spirv-headers/cmake/Config.cmake.in diff --git a/third_party/spirv-tools/external/spirv-headers/example/CMakeLists.txt b/third_party/spirv-headers/example/CMakeLists.txt similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/example/CMakeLists.txt rename to third_party/spirv-headers/example/CMakeLists.txt diff --git a/third_party/spirv-tools/external/spirv-headers/example/example.cpp b/third_party/spirv-headers/example/example.cpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/example/example.cpp rename to third_party/spirv-headers/example/example.cpp diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/GLSL.std.450.h b/third_party/spirv-headers/include/spirv/1.0/GLSL.std.450.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/GLSL.std.450.h rename to third_party/spirv-headers/include/spirv/1.0/GLSL.std.450.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/OpenCL.std.h b/third_party/spirv-headers/include/spirv/1.0/OpenCL.std.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/OpenCL.std.h rename to third_party/spirv-headers/include/spirv/1.0/OpenCL.std.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json b/third_party/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json rename to third_party/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/extinst.opencl.std.100.grammar.json b/third_party/spirv-headers/include/spirv/1.0/extinst.opencl.std.100.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/extinst.opencl.std.100.grammar.json rename to third_party/spirv-headers/include/spirv/1.0/extinst.opencl.std.100.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.core.grammar.json b/third_party/spirv-headers/include/spirv/1.0/spirv.core.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.core.grammar.json rename to third_party/spirv-headers/include/spirv/1.0/spirv.core.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.cs b/third_party/spirv-headers/include/spirv/1.0/spirv.cs similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.cs rename to third_party/spirv-headers/include/spirv/1.0/spirv.cs diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.h b/third_party/spirv-headers/include/spirv/1.0/spirv.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.h rename to third_party/spirv-headers/include/spirv/1.0/spirv.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.hpp b/third_party/spirv-headers/include/spirv/1.0/spirv.hpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.hpp rename to third_party/spirv-headers/include/spirv/1.0/spirv.hpp diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.hpp11 b/third_party/spirv-headers/include/spirv/1.0/spirv.hpp11 similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.hpp11 rename to third_party/spirv-headers/include/spirv/1.0/spirv.hpp11 diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.json b/third_party/spirv-headers/include/spirv/1.0/spirv.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.json rename to third_party/spirv-headers/include/spirv/1.0/spirv.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.lua b/third_party/spirv-headers/include/spirv/1.0/spirv.lua similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.lua rename to third_party/spirv-headers/include/spirv/1.0/spirv.lua diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.py b/third_party/spirv-headers/include/spirv/1.0/spirv.py similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.0/spirv.py rename to third_party/spirv-headers/include/spirv/1.0/spirv.py diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/GLSL.std.450.h b/third_party/spirv-headers/include/spirv/1.1/GLSL.std.450.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/GLSL.std.450.h rename to third_party/spirv-headers/include/spirv/1.1/GLSL.std.450.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/OpenCL.std.h b/third_party/spirv-headers/include/spirv/1.1/OpenCL.std.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/OpenCL.std.h rename to third_party/spirv-headers/include/spirv/1.1/OpenCL.std.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/extinst.glsl.std.450.grammar.json b/third_party/spirv-headers/include/spirv/1.1/extinst.glsl.std.450.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/extinst.glsl.std.450.grammar.json rename to third_party/spirv-headers/include/spirv/1.1/extinst.glsl.std.450.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/extinst.opencl.std.100.grammar.json b/third_party/spirv-headers/include/spirv/1.1/extinst.opencl.std.100.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/extinst.opencl.std.100.grammar.json rename to third_party/spirv-headers/include/spirv/1.1/extinst.opencl.std.100.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.core.grammar.json b/third_party/spirv-headers/include/spirv/1.1/spirv.core.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.core.grammar.json rename to third_party/spirv-headers/include/spirv/1.1/spirv.core.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.cs b/third_party/spirv-headers/include/spirv/1.1/spirv.cs similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.cs rename to third_party/spirv-headers/include/spirv/1.1/spirv.cs diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.h b/third_party/spirv-headers/include/spirv/1.1/spirv.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.h rename to third_party/spirv-headers/include/spirv/1.1/spirv.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.hpp b/third_party/spirv-headers/include/spirv/1.1/spirv.hpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.hpp rename to third_party/spirv-headers/include/spirv/1.1/spirv.hpp diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.hpp11 b/third_party/spirv-headers/include/spirv/1.1/spirv.hpp11 similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.hpp11 rename to third_party/spirv-headers/include/spirv/1.1/spirv.hpp11 diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.json b/third_party/spirv-headers/include/spirv/1.1/spirv.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.json rename to third_party/spirv-headers/include/spirv/1.1/spirv.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.lua b/third_party/spirv-headers/include/spirv/1.1/spirv.lua similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.lua rename to third_party/spirv-headers/include/spirv/1.1/spirv.lua diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.py b/third_party/spirv-headers/include/spirv/1.1/spirv.py similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.1/spirv.py rename to third_party/spirv-headers/include/spirv/1.1/spirv.py diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/GLSL.std.450.h b/third_party/spirv-headers/include/spirv/1.2/GLSL.std.450.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/GLSL.std.450.h rename to third_party/spirv-headers/include/spirv/1.2/GLSL.std.450.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/OpenCL.std.h b/third_party/spirv-headers/include/spirv/1.2/OpenCL.std.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/OpenCL.std.h rename to third_party/spirv-headers/include/spirv/1.2/OpenCL.std.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/extinst.glsl.std.450.grammar.json b/third_party/spirv-headers/include/spirv/1.2/extinst.glsl.std.450.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/extinst.glsl.std.450.grammar.json rename to third_party/spirv-headers/include/spirv/1.2/extinst.glsl.std.450.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/extinst.opencl.std.100.grammar.json b/third_party/spirv-headers/include/spirv/1.2/extinst.opencl.std.100.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/extinst.opencl.std.100.grammar.json rename to third_party/spirv-headers/include/spirv/1.2/extinst.opencl.std.100.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.core.grammar.json b/third_party/spirv-headers/include/spirv/1.2/spirv.core.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.core.grammar.json rename to third_party/spirv-headers/include/spirv/1.2/spirv.core.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.cs b/third_party/spirv-headers/include/spirv/1.2/spirv.cs similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.cs rename to third_party/spirv-headers/include/spirv/1.2/spirv.cs diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.h b/third_party/spirv-headers/include/spirv/1.2/spirv.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.h rename to third_party/spirv-headers/include/spirv/1.2/spirv.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.hpp b/third_party/spirv-headers/include/spirv/1.2/spirv.hpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.hpp rename to third_party/spirv-headers/include/spirv/1.2/spirv.hpp diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.hpp11 b/third_party/spirv-headers/include/spirv/1.2/spirv.hpp11 similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.hpp11 rename to third_party/spirv-headers/include/spirv/1.2/spirv.hpp11 diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.json b/third_party/spirv-headers/include/spirv/1.2/spirv.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.json rename to third_party/spirv-headers/include/spirv/1.2/spirv.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.lua b/third_party/spirv-headers/include/spirv/1.2/spirv.lua similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.lua rename to third_party/spirv-headers/include/spirv/1.2/spirv.lua diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.py b/third_party/spirv-headers/include/spirv/1.2/spirv.py similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/1.2/spirv.py rename to third_party/spirv-headers/include/spirv/1.2/spirv.py diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/spir-v.xml b/third_party/spirv-headers/include/spirv/spir-v.xml similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/spir-v.xml rename to third_party/spirv-headers/include/spirv/spir-v.xml diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h b/third_party/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h rename to third_party/spirv-headers/include/spirv/unified1/AMD_gcn_shader.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h rename to third_party/spirv-headers/include/spirv/unified1/AMD_shader_ballot.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h rename to third_party/spirv-headers/include/spirv/unified1/AMD_shader_explicit_vertex_parameter.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h b/third_party/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h rename to third_party/spirv-headers/include/spirv/unified1/AMD_shader_trinary_minmax.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/DebugInfo.h b/third_party/spirv-headers/include/spirv/unified1/DebugInfo.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/DebugInfo.h rename to third_party/spirv-headers/include/spirv/unified1/DebugInfo.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/GLSL.std.450.h b/third_party/spirv-headers/include/spirv/unified1/GLSL.std.450.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/GLSL.std.450.h rename to third_party/spirv-headers/include/spirv/unified1/GLSL.std.450.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h rename to third_party/spirv-headers/include/spirv/unified1/NonSemanticClspvReflection.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h rename to third_party/spirv-headers/include/spirv/unified1/NonSemanticDebugPrintf.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h b/third_party/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h rename to third_party/spirv-headers/include/spirv/unified1/NonSemanticShaderDebugInfo100.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/OpenCL.std.h b/third_party/spirv-headers/include/spirv/unified1/OpenCL.std.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/OpenCL.std.h rename to third_party/spirv-headers/include/spirv/unified1/OpenCL.std.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h b/third_party/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h rename to third_party/spirv-headers/include/spirv/unified1/OpenCLDebugInfo100.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.debuginfo.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.glsl.std.450.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugprintf.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugprintf.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugprintf.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.debugprintf.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.opencl.std.100.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-gcn-shader.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-gcn-shader.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-gcn-shader.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-gcn-shader.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-ballot.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-ballot.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-ballot.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-ballot.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-trinary-minmax.grammar.json b/third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-trinary-minmax.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-trinary-minmax.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/extinst.spv-amd-shader-trinary-minmax.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.bf b/third_party/spirv-headers/include/spirv/unified1/spirv.bf similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.bf rename to third_party/spirv-headers/include/spirv/unified1/spirv.bf diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json b/third_party/spirv-headers/include/spirv/unified1/spirv.core.grammar.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json rename to third_party/spirv-headers/include/spirv/unified1/spirv.core.grammar.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.cs b/third_party/spirv-headers/include/spirv/unified1/spirv.cs similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.cs rename to third_party/spirv-headers/include/spirv/unified1/spirv.cs diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.h b/third_party/spirv-headers/include/spirv/unified1/spirv.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.h rename to third_party/spirv-headers/include/spirv/unified1/spirv.h diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp b/third_party/spirv-headers/include/spirv/unified1/spirv.hpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp rename to third_party/spirv-headers/include/spirv/unified1/spirv.hpp diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp11 b/third_party/spirv-headers/include/spirv/unified1/spirv.hpp11 similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.hpp11 rename to third_party/spirv-headers/include/spirv/unified1/spirv.hpp11 diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.json b/third_party/spirv-headers/include/spirv/unified1/spirv.json similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.json rename to third_party/spirv-headers/include/spirv/unified1/spirv.json diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.lua b/third_party/spirv-headers/include/spirv/unified1/spirv.lua similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.lua rename to third_party/spirv-headers/include/spirv/unified1/spirv.lua diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.py b/third_party/spirv-headers/include/spirv/unified1/spirv.py similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spirv.py rename to third_party/spirv-headers/include/spirv/unified1/spirv.py diff --git a/third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spv.d b/third_party/spirv-headers/include/spirv/unified1/spv.d similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/include/spirv/unified1/spv.d rename to third_party/spirv-headers/include/spirv/unified1/spv.d diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/CMakeLists.txt b/third_party/spirv-headers/tools/buildHeaders/CMakeLists.txt similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/CMakeLists.txt rename to third_party/spirv-headers/tools/buildHeaders/CMakeLists.txt diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py b/third_party/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py rename to third_party/spirv-headers/tools/buildHeaders/bin/generate_language_headers.py diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py b/third_party/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py rename to third_party/spirv-headers/tools/buildHeaders/bin/makeExtinstHeaders.py diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/bin/makeHeaders b/third_party/spirv-headers/tools/buildHeaders/bin/makeHeaders similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/bin/makeHeaders rename to third_party/spirv-headers/tools/buildHeaders/bin/makeHeaders diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.cpp b/third_party/spirv-headers/tools/buildHeaders/header.cpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.cpp rename to third_party/spirv-headers/tools/buildHeaders/header.cpp diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.h b/third_party/spirv-headers/tools/buildHeaders/header.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/header.h rename to third_party/spirv-headers/tools/buildHeaders/header.h diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp b/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp rename to third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.cpp diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/jsonToSpirv.h b/third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.h similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/jsonToSpirv.h rename to third_party/spirv-headers/tools/buildHeaders/jsonToSpirv.h diff --git a/third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/main.cpp b/third_party/spirv-headers/tools/buildHeaders/main.cpp similarity index 100% rename from third_party/spirv-tools/external/spirv-headers/tools/buildHeaders/main.cpp rename to third_party/spirv-headers/tools/buildHeaders/main.cpp diff --git a/third_party/spirv-tools/CMakeLists.txt b/third_party/spirv-tools/CMakeLists.txt index 8437fd570a3..487a40a4816 100755 --- a/third_party/spirv-tools/CMakeLists.txt +++ b/third_party/spirv-tools/CMakeLists.txt @@ -24,6 +24,8 @@ if (POLICY CMP0054) endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../spirv-headers) + if (APPLE) set(CMAKE_MACOSX_RPATH ON) endif (APPLE) @@ -106,6 +108,7 @@ set(SPIRV_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to c option(SPIRV_BUILD_LIBFUZZER_TARGETS "Build libFuzzer targets" OFF) set(SPIRV_WERROR OFF) + if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))) set(COMPILER_IS_LIKE_GNU TRUE) endif() @@ -313,8 +316,6 @@ option(SPIRV_SKIP_EXECUTABLES ${SPIRV_SKIP_EXECUTABLES_OPTION}) option(SPIRV_SKIP_TESTS "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) - - if ("${SPIRV_SKIP_EXECUTABLES}") set(SPIRV_SKIP_TESTS ON) endif() @@ -378,4 +379,3 @@ endif() set(SPIRV_LIBRARIES "-lSPIRV-Tools-opt -lSPIRV-Tools -lSPIRV-Tools-link") set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared") - diff --git a/third_party/spirv-tools/FILAMENT_README.md b/third_party/spirv-tools/FILAMENT_README.md index 5020b06c78e..9c9bb3e437b 100644 --- a/third_party/spirv-tools/FILAMENT_README.md +++ b/third_party/spirv-tools/FILAMENT_README.md @@ -1,34 +1,20 @@ -When updating spirv-tools to a new version there are several `CMakeLists.txt` files that need -to patched with Filament specific changes. This can be done by running the following command at -Filament's root: +When updating SPIRV-Tools to a new version, run the following from *this* directory ``` -git apply third_party/spirv-tools/filament-specific-changes.patch +bash filament-update.sh [git commit hash] ``` -The following procedure can be used to update spirv-tools. Note that there is a secondary repository -that needs to be downloaded (spirv-headers). +This will pull in the updated source for SPRIV-Tools and pull in the right version of SPIRV-Headers. +The script will also try to apply Filament specific changes to the `CMakeLists.txt`. It could be +that the diff application will fail, in which case, the updater will need to resolve the difference +manually and update `filament-specific-changes.patch`. -``` -curl -L https://github.com/KhronosGroup/spirv-tools/archive/master.zip > master.zip -unzip master.zip -rsync -r SPIRV-Tools-master/ spirv-tools/ --delete -rm -rf SPIRV-Tools-master master.zip -curl -L https://github.com/KhronosGroup/spirv-headers/archive/master.zip > master.zip -unzip master.zip -mv SPIRV-Headers-master/ spirv-tools/external/spirv-headers -rm master.zip +The above script will bring in the changes, but you would still need to add it to a git commit +(i.e. pull request) by doing -git add spirv-tools +``` +git add -u third_party/spriv-tools third_party/spirv-headers ``` -The patch file also edits the `.gitignore` to allow `spirv-headers` to be committed. - -Finally, remember to bring back the Filament-specific changes in CMakeLists. - -To restore this file and the patch file do: +from the Filament source root. -``` -git checkout main spirv-tools/FILAMENT_README.md -git checkout main spirv-tools/filament-specific-changes.patch -``` diff --git a/third_party/spirv-tools/external/CMakeLists.txt b/third_party/spirv-tools/external/CMakeLists.txt index a081e119bf3..179a4012f94 100644 --- a/third_party/spirv-tools/external/CMakeLists.txt +++ b/third_party/spirv-tools/external/CMakeLists.txt @@ -45,6 +45,8 @@ if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) # Do this so enclosing projects can use SPIRV-Headers_SOURCE_DIR to find # headers to include. if (NOT DEFINED SPIRV-Headers_SOURCE_DIR) + set(SPIRV_HEADERS_SKIP_INSTALL ON) + set(SPIRV_HEADERS_SKIP_EXAMPLES ON) add_subdirectory(${SPIRV_HEADER_DIR}) endif() else() diff --git a/third_party/spirv-tools/external/spirv-headers/.github/workflows/presubmit.yml b/third_party/spirv-tools/external/spirv-headers/.github/workflows/presubmit.yml deleted file mode 100644 index d9c25faef5e..00000000000 --- a/third_party/spirv-tools/external/spirv-headers/.github/workflows/presubmit.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Presubmit -on: [push, pull_request] - -jobs: - build: - name: Build ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - steps: - - uses: actions/checkout@v2 - - name: Install Ubuntu packages - if: matrix.os == 'ubuntu-latest' - run: sudo apt install -y dos2unix - - name: Install macOS packages - if: matrix.os == 'macos-latest' - run: brew install dos2unix - - name: Build - run: | - mkdir build - cd build - cmake -DCMAKE_INSTALL_PREFIX=install .. - cmake --build . --target install - - name: Build spec tools - run: | - cd tools/buildHeaders - mkdir build - cd build - cmake .. - cmake --build . --target install - - name: Build headers - run: | - cd tools/buildHeaders - ./bin/makeHeaders - - name: Check generated headers - run: git diff --exit-code diff --git a/third_party/spirv-tools/filament-specific-changes.patch b/third_party/spirv-tools/filament-specific-changes.patch index a6d1fb52135..8f545857427 100644 --- a/third_party/spirv-tools/filament-specific-changes.patch +++ b/third_party/spirv-tools/filament-specific-changes.patch @@ -1,24 +1,22 @@ -diff --git a/third_party/spirv-tools/.gitignore b/third_party/spirv-tools/.gitignore -index ec709ba79..a87496a7d 100644 ---- a/third_party/spirv-tools/.gitignore -+++ b/third_party/spirv-tools/.gitignore -@@ -5,8 +5,6 @@ compile_commands.json - /build*/ - /buildtools/ - /external/googletest --/external/SPIRV-Headers --/external/spirv-headers - /external/effcee - /external/re2 - /external/protobuf diff --git a/third_party/spirv-tools/CMakeLists.txt b/third_party/spirv-tools/CMakeLists.txt index 76b87d8c5..53b3404d1 100755 --- a/third_party/spirv-tools/CMakeLists.txt +++ b/third_party/spirv-tools/CMakeLists.txt -@@ -24,8 +24,14 @@ if (POLICY CMP0054) +@@ -12,7 +12,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-cmake_minimum_required(VERSION 2.8.12) ++cmake_minimum_required(VERSION 3.19) + if (POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) + endif() +@@ -24,8 +24,16 @@ if (POLICY CMP0054) endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) - + ++set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../spirv-headers) ++ +if (APPLE) + set(CMAKE_MACOSX_RPATH ON) +endif (APPLE) @@ -63,7 +61,7 @@ index 76b87d8c5..53b3404d1 100755 # Check for symbol exports on Linux. # At the moment, this check will fail on the OSX build machines for the Android NDK. -@@ -286,11 +297,13 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) +@@ -286,11 +297,11 @@ if(ENABLE_SPIRV_TOOLS_INSTALL) endif() # Defaults to OFF if the user didn't set it. @@ -72,13 +70,11 @@ index 76b87d8c5..53b3404d1 100755 - ${SPIRV_SKIP_EXECUTABLES}) -option(SPIRV_SKIP_TESTS - "Skip building tests along with the library" ${SPIRV_SKIP_TESTS}) -+ option(SPIRV_SKIP_EXECUTABLES -+ "Skip building the executable and tests along with the library" -+ ${SPIRV_SKIP_EXECUTABLES_OPTION}) -+ option(SPIRV_SKIP_TESTS -+ "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) -+ -+ ++option(SPIRV_SKIP_EXECUTABLES ++ "Skip building the executable and tests along with the library" ++ ${SPIRV_SKIP_EXECUTABLES_OPTION}) ++option(SPIRV_SKIP_TESTS ++ "Skip building tests along with the library" ${SPIRV_SKIP_TESTS_OPTION}) if ("${SPIRV_SKIP_EXECUTABLES}") set(SPIRV_SKIP_TESTS ON) endif() @@ -131,36 +127,6 @@ index 76b87d8c5..53b3404d1 100755 - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif() -diff --git a/third_party/spirv-tools/FILAMENT_README.md b/third_party/spirv-tools/FILAMENT_README.md -index 39e4620a0..3aa363ebf 100644 ---- a/third_party/spirv-tools/FILAMENT_README.md -+++ b/third_party/spirv-tools/FILAMENT_README.md -@@ -1,9 +1,6 @@ --When updating spirv-tools to a new version, make sure to preserve all the changes marked with --the following in `CMakeLists.txt` and `source/CMakeLists.txt`: -- --`# Filament specific changes` -- --You can easily apply these changes by running the following command at Filament's root: -+When updating spirv-tools to a new version there are several `CMakeLists.txt` files that need -+to patched with Filament specific changes. This can be done by running the following command at -+Filament's root: - - ``` - git apply third_party/spirv-tools/filament-specific-changes.patch -diff --git a/third_party/spirv-tools/external/CMakeLists.txt b/third_party/spirv-tools/external/CMakeLists.txt -index 179a4012f..a081e119b 100644 ---- a/third_party/spirv-tools/external/CMakeLists.txt -+++ b/third_party/spirv-tools/external/CMakeLists.txt -@@ -45,8 +45,6 @@ if (IS_DIRECTORY ${SPIRV_HEADER_DIR}) - # Do this so enclosing projects can use SPIRV-Headers_SOURCE_DIR to find - # headers to include. - if (NOT DEFINED SPIRV-Headers_SOURCE_DIR) -- set(SPIRV_HEADERS_SKIP_INSTALL ON) -- set(SPIRV_HEADERS_SKIP_EXAMPLES ON) - add_subdirectory(${SPIRV_HEADER_DIR}) - endif() - else() diff --git a/third_party/spirv-tools/source/CMakeLists.txt b/third_party/spirv-tools/source/CMakeLists.txt index 98559b8fe..0734d6a82 100644 --- a/third_party/spirv-tools/source/CMakeLists.txt @@ -194,21 +160,3 @@ index 98559b8fe..0734d6a82 100644 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -diff --git a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt -index 147f7adee..d8d1d7e35 100644 ---- a/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt -+++ b/third_party/spirv-tools/external/spirv-headers/CMakeLists.txt -@@ -49,11 +49,9 @@ add_custom_target(install-headers - COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv - $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv) - --option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" -- ${SPIRV_HEADERS_SKIP_EXAMPLES}) -+option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) - --option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" -- ${SPIRV_HEADERS_SKIP_INSTALL}) -+option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) - - if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) - set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-tools/filament-update.sh b/third_party/spirv-tools/filament-update.sh new file mode 100644 index 00000000000..5e52c24d215 --- /dev/null +++ b/third_party/spirv-tools/filament-update.sh @@ -0,0 +1,53 @@ +# Copyright (C) 2023 The Android Open Source Project +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# This script is used to update SPIRV-Tools from source. +# This script takes in a git commit hash as an argument. + +#!/usr/bin/env bash + +TOOLS_HASH=$1 + +function sync_khronos_repo() { + local REPO=$1 + local HASH=$2 + pushd . + cd /tmp + rm -rf ${REPO} && git clone git@github.com:KhronosGroup/${REPO}.git + cd ${REPO} + git reset --hard ${HASH} + popd +} + +# First we update SPIRV-Tools to the given git hash +sync_khronos_repo SPIRV-Tools ${TOOLS_HASH} + +rsync -r /tmp/SPIRV-Tools/ ./ --delete +rm -rf .git .github +# Recover the filament specific files lost in the above rsync +git checkout filament-specific-changes.patch FILAMENT_README.md filament-update.sh +git apply filament-specific-changes.patch + +HEADERS_HASH=`grep "spirv_headers_revision\':" DEPS | awk '{ print $2 }' | sed "s/[\'\,\\n]//g"` + +# Next we update SPIRV-Headers to the right hash (dependency as given by SPIRV-Tools) +sync_khronos_repo SPIRV-Headers ${HEADERS_HASH} + +pushd . +cd ../spirv-headers +rsync -r /tmp/SPIRV-Headers/ ./ --delete +rm -rf .git .github +# Recover the filament specific files lost in the above rsync +git checkout FILAMENT_README.md +popd From b517a45213d3bdc0b036c0613f11639591a4b2bf Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Tue, 5 Dec 2023 11:28:42 -0800 Subject: [PATCH 11/20] Fix sed in bump-version.sh for Linux (#7406) --- build/common/bump-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common/bump-version.sh b/build/common/bump-version.sh index 7d201880fbe..9613a764ff6 100755 --- a/build/common/bump-version.sh +++ b/build/common/bump-version.sh @@ -50,7 +50,7 @@ function replace { FIND_STR="${1//\{\{VERSION\}\}/${VERSION_REGEX}}" REPLACE_STR="${1//\{\{VERSION\}\}/${NEW_VERSION}}" local FILE_NAME="$2" - if [ IS_DARWIN ]; then + if [ IS_DARWIN == 1 ]; then sed -i '' -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}" else sed -i -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}" From 35a00b1d84acd52e921b0de2e740dfae010c49c1 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Tue, 5 Dec 2023 11:30:48 -0800 Subject: [PATCH 12/20] Release Filament 1.48.0 --- NEW_RELEASE_NOTES.md | 1 - README.md | 4 ++-- RELEASE_NOTES.md | 4 ++++ android/gradle.properties | 2 +- ios/CocoaPods/Filament.podspec | 4 ++-- web/filament-js/package.json | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index 59d7dab31c6..c3161a7700b 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -8,4 +8,3 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut -- matc: Fix ESSL 1.0 codegen when using external samplers [⚠️ **Recompile materials**] diff --git a/README.md b/README.md index b0278db43f3..50bcf1ecec1 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.47.0' + implementation 'com.google.android.filament:filament-android:1.48.0' } ``` @@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`: iOS projects can use CocoaPods to install the latest release: ```shell -pod 'Filament', '~> 1.47.0' +pod 'Filament', '~> 1.48.0' ``` ### Snapshots diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3459c5001f8..6b9ce2dd219 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,10 @@ A new header is inserted each time a *tag* is created. Instead, if you are authoring a PR for the main branch, add your release note to [NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md). +## v1.49.0 + +- matc: Fix ESSL 1.0 codegen when using external samplers [⚠️ **Recompile materials**] + ## v1.48.0 - matc: New option `-1` to disable generation of ESSL 1.0 code in Feature Level 0 materials diff --git a/android/gradle.properties b/android/gradle.properties index 6dda5b45e97..db2639526bc 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.47.0 +VERSION_NAME=1.48.0 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 24db7659fb0..3d4af657f04 100644 --- a/ios/CocoaPods/Filament.podspec +++ b/ios/CocoaPods/Filament.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = "Filament" - spec.version = "1.47.0" + spec.version = "1.48.0" spec.license = { :type => "Apache 2.0", :file => "LICENSE" } spec.homepage = "https://google.github.io/filament" spec.authors = "Google LLC." spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL." spec.platform = :ios, "11.0" - spec.source = { :http => "https://github.com/google/filament/releases/download/v1.47.0/filament-v1.47.0-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.48.0/filament-v1.48.0-ios.tgz" } # Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon. spec.pod_target_xcconfig = { diff --git a/web/filament-js/package.json b/web/filament-js/package.json index ef4cd7e79d9..b97c7364479 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.47.0", + "version": "1.48.0", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js", From 9140d44b292b4cc0e04ca18e7a2a02c107666af0 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Tue, 5 Dec 2023 11:39:05 -0800 Subject: [PATCH 13/20] Bump version to 1.49.0 --- README.md | 4 ++-- android/gradle.properties | 2 +- ios/CocoaPods/Filament.podspec | 4 ++-- web/filament-js/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 50bcf1ecec1..f77102a883b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.48.0' + implementation 'com.google.android.filament:filament-android:1.49.0' } ``` @@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`: iOS projects can use CocoaPods to install the latest release: ```shell -pod 'Filament', '~> 1.48.0' +pod 'Filament', '~> 1.49.0' ``` ### Snapshots diff --git a/android/gradle.properties b/android/gradle.properties index db2639526bc..da891d4d73b 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.48.0 +VERSION_NAME=1.49.0 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 3d4af657f04..12de62510f7 100644 --- a/ios/CocoaPods/Filament.podspec +++ b/ios/CocoaPods/Filament.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = "Filament" - spec.version = "1.48.0" + spec.version = "1.49.0" spec.license = { :type => "Apache 2.0", :file => "LICENSE" } spec.homepage = "https://google.github.io/filament" spec.authors = "Google LLC." spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL." spec.platform = :ios, "11.0" - spec.source = { :http => "https://github.com/google/filament/releases/download/v1.48.0/filament-v1.48.0-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.49.0/filament-v1.49.0-ios.tgz" } # Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon. spec.pod_target_xcconfig = { diff --git a/web/filament-js/package.json b/web/filament-js/package.json index b97c7364479..653aa176c81 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.48.0", + "version": "1.49.0", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js", From b219113a55896d37ea2499c9b0c59d794daabf99 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Thu, 7 Dec 2023 14:49:12 -0800 Subject: [PATCH 14/20] vk: spec const workaround through runtime spirv modification (#7399) To avoid driver edge cases with spec const, we manually change the spec const into a regular constant in the spirv. FIXES=310603393 --- CMakeLists.txt | 2 + filament/backend/CMakeLists.txt | 3 + .../backend/include/backend/DriverEnums.h | 4 +- filament/backend/src/vulkan/VulkanDriver.cpp | 6 +- filament/backend/src/vulkan/VulkanHandles.cpp | 58 +++----- filament/backend/src/vulkan/VulkanHandles.h | 21 +-- .../src/vulkan/VulkanPipelineCache.cpp | 3 - .../backend/src/vulkan/VulkanPipelineCache.h | 1 - .../src/vulkan/spirv/VulkanSpirvUtils.cpp | 125 ++++++++++++++++++ .../src/vulkan/spirv/VulkanSpirvUtils.h | 43 ++++++ 10 files changed, 200 insertions(+), 66 deletions(-) create mode 100644 filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp create mode 100644 filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c2bb29685..e1dd12d71b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -743,6 +743,8 @@ endif() if (FILAMENT_SUPPORTS_VULKAN) add_subdirectory(${LIBRARIES}/bluevk) add_subdirectory(${EXTERNAL}/vkmemalloc/tnt) + set(SPIRV_HEADERS_SKIP_EXAMPLES ON) + add_subdirectory(${EXTERNAL}/spirv-headers) endif() set(FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples) diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt index 0420162a411..4edf04af14e 100644 --- a/filament/backend/CMakeLists.txt +++ b/filament/backend/CMakeLists.txt @@ -169,6 +169,8 @@ if (FILAMENT_SUPPORTS_VULKAN) src/vulkan/platform/VulkanPlatform.cpp src/vulkan/platform/VulkanPlatformSwapChainImpl.cpp src/vulkan/platform/VulkanPlatformSwapChainImpl.h + src/vulkan/spirv/VulkanSpirvUtils.cpp + src/vulkan/spirv/VulkanSpirvUtils.h src/vulkan/VulkanBlitter.cpp src/vulkan/VulkanBlitter.h src/vulkan/VulkanBuffer.cpp @@ -313,6 +315,7 @@ endif() if (FILAMENT_SUPPORTS_VULKAN) target_link_libraries(${TARGET} PUBLIC bluevk vkmemalloc vkshaders smol-v) + target_link_libraries(${TARGET} PRIVATE SPIRV-Headers) endif() if (FILAMENT_SUPPORTS_METAL) diff --git a/filament/backend/include/backend/DriverEnums.h b/filament/backend/include/backend/DriverEnums.h index 1dd11cd455d..80a26f3621f 100644 --- a/filament/backend/include/backend/DriverEnums.h +++ b/filament/backend/include/backend/DriverEnums.h @@ -1180,8 +1180,8 @@ using FrameScheduledCallback = void(*)(PresentCallable callable, void* user); enum class Workaround : uint16_t { // The EASU pass must split because shader compiler flattens early-exit branch SPLIT_EASU, - // Backend allows feedback loop with ancillary buffers (depth/stencil) as long as they're read-only for - // the whole render pass. + // Backend allows feedback loop with ancillary buffers (depth/stencil) as long as they're + // read-only for the whole render pass. ALLOW_READ_ONLY_ANCILLARY_FEEDBACK_LOOP, // for some uniform arrays, it's needed to do an initialization to avoid crash on adreno gpu ADRENO_UNIFORM_ARRAY_CRASH, diff --git a/filament/backend/src/vulkan/VulkanDriver.cpp b/filament/backend/src/vulkan/VulkanDriver.cpp index d64b0a69e54..d4c2a5b48c3 100644 --- a/filament/backend/src/vulkan/VulkanDriver.cpp +++ b/filament/backend/src/vulkan/VulkanDriver.cpp @@ -54,7 +54,8 @@ VmaAllocator createAllocator(VkInstance instance, VkPhysicalDevice physicalDevic VmaAllocator allocator; VmaVulkanFunctions const funcs { #if VMA_DYNAMIC_VULKAN_FUNCTIONS - .vkGetInstanceProcAddr = vkGetInstanceProcAddr, .vkGetDeviceProcAddr = vkGetDeviceProcAddr, + .vkGetInstanceProcAddr = vkGetInstanceProcAddr, + .vkGetDeviceProcAddr = vkGetDeviceProcAddr, #else .vkGetPhysicalDeviceProperties = vkGetPhysicalDeviceProperties, .vkGetPhysicalDeviceMemoryProperties = vkGetPhysicalDeviceMemoryProperties, @@ -426,7 +427,8 @@ void VulkanDriver::destroyTexture(Handle th) { } void VulkanDriver::createProgramR(Handle ph, Program&& program) { - auto vkprogram = mResourceAllocator.construct(ph, mPlatform->getDevice(), program); + auto vkprogram + = mResourceAllocator.construct(ph, mPlatform->getDevice(), program); mResourceManager.acquire(vkprogram); } diff --git a/filament/backend/src/vulkan/VulkanHandles.cpp b/filament/backend/src/vulkan/VulkanHandles.cpp index ac6b4ccea17..5dfce4ddfbd 100644 --- a/filament/backend/src/vulkan/VulkanHandles.cpp +++ b/filament/backend/src/vulkan/VulkanHandles.cpp @@ -18,6 +18,7 @@ #include "VulkanConstants.h" #include "VulkanMemory.h" +#include "spirv/VulkanSpirvUtils.h" #include @@ -46,61 +47,34 @@ static void clampToFramebuffer(VkRect2D* rect, uint32_t fbWidth, uint32_t fbHeig rect->extent.height = std::max(top - y, 0); } -VulkanProgram::VulkanProgram(VkDevice device, const Program& builder) noexcept +VulkanProgram::VulkanProgram(VkDevice device, Program& builder) noexcept : HwProgram(builder.getName()), VulkanResource(VulkanResourceType::PROGRAM), - mInfo(new PipelineInfo(builder.getSpecializationConstants().size())), + mInfo(new PipelineInfo()), mDevice(device) { - auto& blobs = builder.getShadersSource(); + Program::ShaderSource& blobs = builder.getShadersSource(); auto& modules = mInfo->shaders; + + auto const& specializationConstants = builder.getSpecializationConstants(); + for (size_t i = 0; i < MAX_SHADER_MODULES; i++) { - const auto& blob = blobs[i]; - uint32_t* data = (uint32_t*)blob.data(); + Program::ShaderBlob& blob = blobs[i]; + + workaroundSpecConstant(blob, specializationConstants); + + uint32_t* data = (uint32_t*) blob.data(); + size_t dataSize = blob.size(); + VkShaderModule& module = modules[i]; VkShaderModuleCreateInfo moduleInfo = { .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, - .codeSize = blob.size(), + .codeSize = dataSize, .pCode = data, }; VkResult result = vkCreateShaderModule(mDevice, &moduleInfo, VKALLOC, &module); ASSERT_POSTCONDITION(result == VK_SUCCESS, "Unable to create shader module."); } - // Note that bools are 4-bytes in Vulkan - // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkBool32.html - constexpr uint32_t const CONSTANT_SIZE = 4; - - // populate the specialization constants requirements right now - auto const& specializationConstants = builder.getSpecializationConstants(); - uint32_t const specConstCount = static_cast(specializationConstants.size()); - char* specData = mInfo->specConstData.get(); - if (specConstCount > 0) { - mInfo->specializationInfo = { - .mapEntryCount = specConstCount, - .pMapEntries = mInfo->specConsts.data(), - .dataSize = specConstCount * CONSTANT_SIZE, - .pData = specData, - }; - } - for (uint32_t i = 0; i < specConstCount; ++i) { - uint32_t const offset = i * CONSTANT_SIZE; - mInfo->specConsts[i] = { - .constantID = specializationConstants[i].id, - .offset = offset, - .size = CONSTANT_SIZE, - }; - using SpecConstant = Program::SpecializationConstant::Type; - char const* addr = (char*)specData + offset; - SpecConstant const& arg = specializationConstants[i].value; - if (std::holds_alternative(arg)) { - *((VkBool32*)addr) = std::get(arg) ? VK_TRUE : VK_FALSE; - } else if (std::holds_alternative(arg)) { - *((float*)addr) = std::get(arg); - } else { - *((int32_t*)addr) = std::get(arg); - } - } - auto& groupInfo = builder.getSamplerGroupInfo(); auto& bindingToSamplerIndex = mInfo->bindingToSamplerIndex; auto& usage = mInfo->usage; @@ -123,7 +97,7 @@ VulkanProgram::VulkanProgram(VkDevice device, const Program& builder) noexcept VulkanProgram::VulkanProgram(VkDevice device, VkShaderModule vs, VkShaderModule fs, CustomSamplerInfoList const& samplerInfo) noexcept : VulkanResource(VulkanResourceType::PROGRAM), - mInfo(new PipelineInfo(0)), + mInfo(new PipelineInfo()), mDevice(device) { mInfo->shaders[0] = vs; mInfo->shaders[1] = fs; diff --git a/filament/backend/src/vulkan/VulkanHandles.h b/filament/backend/src/vulkan/VulkanHandles.h index f60d73ca550..043abc05065 100644 --- a/filament/backend/src/vulkan/VulkanHandles.h +++ b/filament/backend/src/vulkan/VulkanHandles.h @@ -25,7 +25,6 @@ #include "VulkanResources.h" #include "VulkanSwapChain.h" #include "VulkanTexture.h" -#include "VulkanUtility.h" #include "private/backend/SamplerGroup.h" @@ -38,7 +37,7 @@ class VulkanTimestamps; struct VulkanProgram : public HwProgram, VulkanResource { - VulkanProgram(VkDevice device, const Program& builder) noexcept; + VulkanProgram(VkDevice device, Program& builder) noexcept; struct CustomSamplerInfo { uint8_t groupIndex; @@ -65,21 +64,14 @@ struct VulkanProgram : public HwProgram, VulkanResource { return mInfo->bindingToSamplerIndex; } - inline VkSpecializationInfo const& getSpecConstInfo() const { - return mInfo->specializationInfo; - } - private: // TODO: handle compute shaders. // The expected order of shaders - from frontend to backend - is vertex, fragment, compute. - static constexpr uint8_t MAX_SHADER_MODULES = 2; + static constexpr uint8_t const MAX_SHADER_MODULES = 2; struct PipelineInfo { - PipelineInfo(size_t specConstsCount) : - bindingToSamplerIndex(MAX_SAMPLER_COUNT, 0xffff), - specConsts(specConstsCount, VkSpecializationMapEntry{}), - specConstData(new char[specConstsCount * 4]) - {} + PipelineInfo() + : bindingToSamplerIndex(MAX_SAMPLER_COUNT, 0xffff) {} // This bitset maps to each of the sampler in the sampler groups associated with this // program, and whether each sampler is used in which shader (i.e. vert, frag, compute). @@ -87,10 +79,7 @@ struct VulkanProgram : public HwProgram, VulkanResource { // We store the samplerGroupIndex as the top 8-bit and the index within each group as the lower 8-bit. utils::FixedCapacityVector bindingToSamplerIndex; - VkShaderModule shaders[MAX_SHADER_MODULES] = {VK_NULL_HANDLE}; - VkSpecializationInfo specializationInfo = {}; - utils::FixedCapacityVector specConsts; - std::unique_ptr specConstData; + VkShaderModule shaders[MAX_SHADER_MODULES] = { VK_NULL_HANDLE }; }; PipelineInfo* mInfo; diff --git a/filament/backend/src/vulkan/VulkanPipelineCache.cpp b/filament/backend/src/vulkan/VulkanPipelineCache.cpp index 000f8c755c3..889888cd083 100644 --- a/filament/backend/src/vulkan/VulkanPipelineCache.cpp +++ b/filament/backend/src/vulkan/VulkanPipelineCache.cpp @@ -360,9 +360,7 @@ VulkanPipelineCache::PipelineCacheEntry* VulkanPipelineCache::createPipeline() n // If we reach this point, we need to create and stash a brand new pipeline object. shaderStages[0].module = mPipelineRequirements.shaders[0]; - shaderStages[0].pSpecializationInfo = mSpecializationRequirements; shaderStages[1].module = mPipelineRequirements.shaders[1]; - shaderStages[1].pSpecializationInfo = mSpecializationRequirements; // Expand our size-optimized structs into the proper Vk structs. uint32_t numVertexAttribs = 0; @@ -568,7 +566,6 @@ VulkanPipelineCache::PipelineLayoutCacheEntry* VulkanPipelineCache::getOrCreateP void VulkanPipelineCache::bindProgram(VulkanProgram* program) noexcept { mPipelineRequirements.shaders[0] = program->getVertexShader(); mPipelineRequirements.shaders[1] = program->getFragmentShader(); - mSpecializationRequirements = &program->getSpecConstInfo(); } void VulkanPipelineCache::bindRasterState(const RasterState& rasterState) noexcept { diff --git a/filament/backend/src/vulkan/VulkanPipelineCache.h b/filament/backend/src/vulkan/VulkanPipelineCache.h index 0e092e9555f..018fd00efec 100644 --- a/filament/backend/src/vulkan/VulkanPipelineCache.h +++ b/filament/backend/src/vulkan/VulkanPipelineCache.h @@ -416,7 +416,6 @@ class VulkanPipelineCache : public CommandBufferObserver { RasterState mCurrentRasterState; PipelineKey mPipelineRequirements = {}; DescriptorKey mDescriptorRequirements = {}; - VkSpecializationInfo const* mSpecializationRequirements = nullptr; // Current bindings for the pipeline and descriptor sets. PipelineKey mBoundPipeline = {}; diff --git a/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp new file mode 100644 index 00000000000..a72c0e8698e --- /dev/null +++ b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "VulkanSpirvUtils.h" + +#include + +#include +#include + +#include + +namespace filament::backend { + +using namespace bluevk; + +namespace { + +// This function transforms an OpSpecConstant instruction into just a OpConstant instruction. +// Additionally, it will adjust the value of the constant as given by the program. +void getTransformedConstantInst(SpecConstantValue const& value, uint32_t* inst) { + + // The first word is the size of the instruction and the instruction type. + // The second word is the type of the instruction. + // The third word is the "result id" (i.e. the variable to store into). + // The fourth word (only for floats and ints) is the literal representing the value. + // We only want to change the first and fourth words. + constexpr size_t const OP = 0; + constexpr size_t const VALUE = 3; + + if (std::holds_alternative(value)) { + inst[OP] = (3 << 16) + | (std::get(value) ? spv::Op::OpConstantTrue : spv::Op::OpConstantFalse); + } else if (std::holds_alternative(value)) { + float const fval = std::get(value); + inst[OP] = (4 << 16) | spv::Op::OpConstant; + inst[VALUE] = *reinterpret_cast(&fval); + } else { + int const ival = std::get(value); + inst[OP] = (4 << 16) | spv::Op::OpConstant; + inst[VALUE] = *reinterpret_cast(&ival); + } +} + +} // anonymous namespace + +void workaroundSpecConstant(Program::ShaderBlob& blob, + utils::FixedCapacityVector const& specConstants) { + using WordMap = std::unordered_map; + using SpecValueMap = std::unordered_map; + + WordMap varToIdMap; + SpecValueMap idToValue; + + for (auto spec: specConstants) { + idToValue[spec.id] = spec.value; + } + + // The follow loop will iterate through all the instructions and look for instructions of the + // form: + // + // OpDecorate %1 SpecId 0 + // %1 = OpSpecConstantFalse %bool + // + // We want to track the mapping between the variable id %1 and the specId 0. And when seeing a + // %1 as the result, we want to change that instruction to just an OpConsant where the constant + // value is adjusted by the spec values provided in the program. + // Additionally, we will turn the SpecId decorations to no-ops. + uint32_t* outputData = (uint32_t*) blob.data(); + + for (uint32_t cursor = 5, cursorEnd = blob.size() / 4; cursor < cursorEnd;) { + uint32_t const firstWord = outputData[cursor]; + uint32_t const wordCount = firstWord >> 16; + uint32_t const op = firstWord & 0x0000FFFF; + + switch(op) { + case spv::Op::OpDecorate: { + if (outputData[cursor + 2] == spv::Decoration::DecorationSpecId) { + uint32_t const targetVar = outputData[cursor + 1]; + uint32_t const specId = outputData[cursor + 3]; + varToIdMap[targetVar] = specId; + // Now we write noops over the decoration since its no longer needed. + for (size_t i = cursor, n = cursor + wordCount; i < n; ++i) { + outputData[i] = (1 << 16) | spv::Op::OpNop; + } + } + break; + } + case spv::Op::OpSpecConstant: + case spv::Op::OpSpecConstantTrue: + case spv::Op::OpSpecConstantFalse: { + uint32_t const targetVar = outputData[cursor + 2]; + + UTILS_UNUSED_IN_RELEASE WordMap::const_iterator idItr = varToIdMap.find(targetVar); + assert_invariant(idItr != varToIdMap.end() && + "Cannot find variable previously decorated with SpecId"); + + assert_invariant(idToValue.find(idItr->second) != idToValue.end() && + "Spec constant value not provided"); + + auto const& val = idToValue[varToIdMap[targetVar]]; + getTransformedConstantInst(val, &outputData[cursor]); + break; + } + default: + break; + } + cursor += wordCount; + } +} + +} // namespace filament::backend diff --git a/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h new file mode 100644 index 00000000000..8251ba3856b --- /dev/null +++ b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TNT_FILAMENT_BACKEND_VULKANSPIRVUTILS_H +#define TNT_FILAMENT_BACKEND_VULKANSPIRVUTILS_H + +#include "backend/Program.h" + +#include + +#include + +namespace filament::backend { + +using SpecConstantValue = Program::SpecializationConstant::Type; + +// For certain drivers, using spec constant can lead to compile errors [1] or undesirable behaviors +// [2]. In those instances, we simply change the spirv and set them to constants. This function will +// modify the blob (but it's safe to do so since blobs are "moved" to the backend). +// +// [1]: QC driver cannot use spec constant to size fields +// (https://github.com/google/filament/issues/6444). +// [2]: An internal driver does not DCE a block guarded by a spec-const boolean set to false +// (b/310603393). +void workaroundSpecConstant(Program::ShaderBlob& blob, + utils::FixedCapacityVector const& specConstants); + +} // namespace filament::backend + +#endif // TNT_FILAMENT_BACKEND_VULKANSPIRVUTILS_H From 753fb102c4a697a1bc72920b26c8038f4aaeb955 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Thu, 7 Dec 2023 17:21:25 -0800 Subject: [PATCH 15/20] spirv-headers: fix failed headers check (#7416) Due to a cmake misconfiguration, we are installing spirv as part of the release, public headers. It's now corrected. --- third_party/spirv-headers/CMakeLists.txt | 8 +++--- .../filament-specific-changes.patch | 27 +++++++++++++++++++ .../spirv-tools/.github/workflows/wasm.yml | 14 ---------- third_party/spirv-tools/.gitignore | 2 ++ third_party/spirv-tools/filament-update.sh | 5 ++-- 5 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 third_party/spirv-headers/filament-specific-changes.patch delete mode 100644 third_party/spirv-tools/.github/workflows/wasm.yml diff --git a/third_party/spirv-headers/CMakeLists.txt b/third_party/spirv-headers/CMakeLists.txt index 9cfba73af29..2b8bb5e5959 100644 --- a/third_party/spirv-headers/CMakeLists.txt +++ b/third_party/spirv-headers/CMakeLists.txt @@ -28,7 +28,7 @@ # The SPIR-V headers from the SPIR-V Registry # https://www.khronos.org/registry/spir-v/ # -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.19) project(SPIRV-Headers VERSION 1.5.5) # There are two ways to use this project. @@ -44,11 +44,9 @@ project(SPIRV-Headers VERSION 1.5.5) # 2. cmake .. # 3. cmake --build . --target install -option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" - ${SPIRV_HEADERS_SKIP_EXAMPLES}) +option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) -option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" - ${SPIRV_HEADERS_SKIP_INSTALL}) +option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-headers/filament-specific-changes.patch b/third_party/spirv-headers/filament-specific-changes.patch new file mode 100644 index 00000000000..b9ddb551ae4 --- /dev/null +++ b/third_party/spirv-headers/filament-specific-changes.patch @@ -0,0 +1,27 @@ +diff --git a/third_party/spirv-headers/CMakeLists.txt b/third_party/spirv-headers/CMakeLists.txt +index 9cfba73af..2b8bb5e59 100644 +--- a/third_party/spirv-headers/CMakeLists.txt ++++ b/third_party/spirv-headers/CMakeLists.txt +@@ -28,7 +28,7 @@ + # The SPIR-V headers from the SPIR-V Registry + # https://www.khronos.org/registry/spir-v/ + # +-cmake_minimum_required(VERSION 3.0) ++cmake_minimum_required(VERSION 3.19) + project(SPIRV-Headers VERSION 1.5.5) + + # There are two ways to use this project. +@@ -44,11 +44,9 @@ project(SPIRV-Headers VERSION 1.5.5) + # 2. cmake .. + # 3. cmake --build . --target install + +-option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" +- ${SPIRV_HEADERS_SKIP_EXAMPLES}) ++option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" ON) + +-option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" +- ${SPIRV_HEADERS_SKIP_INSTALL}) ++option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" ON) + + if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) + set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) diff --git a/third_party/spirv-tools/.github/workflows/wasm.yml b/third_party/spirv-tools/.github/workflows/wasm.yml deleted file mode 100644 index d9a9c5cb7c1..00000000000 --- a/third_party/spirv-tools/.github/workflows/wasm.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Wasm Build - -on: [ push, pull_request ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build web - run: docker-compose up - - name: Run tests - run: node test/wasm/test.js diff --git a/third_party/spirv-tools/.gitignore b/third_party/spirv-tools/.gitignore index a87496a7d97..ec709ba79df 100644 --- a/third_party/spirv-tools/.gitignore +++ b/third_party/spirv-tools/.gitignore @@ -5,6 +5,8 @@ compile_commands.json /build*/ /buildtools/ /external/googletest +/external/SPIRV-Headers +/external/spirv-headers /external/effcee /external/re2 /external/protobuf diff --git a/third_party/spirv-tools/filament-update.sh b/third_party/spirv-tools/filament-update.sh index 5e52c24d215..95149ccd442 100644 --- a/third_party/spirv-tools/filament-update.sh +++ b/third_party/spirv-tools/filament-update.sh @@ -39,7 +39,7 @@ rm -rf .git .github git checkout filament-specific-changes.patch FILAMENT_README.md filament-update.sh git apply filament-specific-changes.patch -HEADERS_HASH=`grep "spirv_headers_revision\':" DEPS | awk '{ print $2 }' | sed "s/[\'\,\\n]//g"` +HEADERS_HASH=`grep "spirv_headers_revision':" DEPS | awk '{ print $2 }' | sed "s/[\'\,\\n]//g"` # Next we update SPIRV-Headers to the right hash (dependency as given by SPIRV-Tools) sync_khronos_repo SPIRV-Headers ${HEADERS_HASH} @@ -49,5 +49,6 @@ cd ../spirv-headers rsync -r /tmp/SPIRV-Headers/ ./ --delete rm -rf .git .github # Recover the filament specific files lost in the above rsync -git checkout FILAMENT_README.md +git checkout filament-specific-changes.patch FILAMENT_README.md +git apply filament-specific-changes.patch popd From d4f08dafbbadb63d672c2fd8ab637abac125953f Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Fri, 8 Dec 2023 10:32:18 -0800 Subject: [PATCH 16/20] vk: workaround swiftshader spirv no-op issue (#7417) Swiftshader runs spirv validation before compilation. However, the validation does not like having Nop (no-op) in the input. So we skip instructions instead of writing no-op for the output of `workaroundSpecConstant`. Also, fix issue to keep the value in the original shader if a specialization wasn't provided. --- filament/backend/src/vulkan/VulkanHandles.cpp | 17 ++-- filament/backend/src/vulkan/VulkanHandles.h | 2 +- .../src/vulkan/spirv/VulkanSpirvUtils.cpp | 87 ++++++++++++------- .../src/vulkan/spirv/VulkanSpirvUtils.h | 12 ++- 4 files changed, 75 insertions(+), 43 deletions(-) diff --git a/filament/backend/src/vulkan/VulkanHandles.cpp b/filament/backend/src/vulkan/VulkanHandles.cpp index 5dfce4ddfbd..bb7f986993e 100644 --- a/filament/backend/src/vulkan/VulkanHandles.cpp +++ b/filament/backend/src/vulkan/VulkanHandles.cpp @@ -22,7 +22,7 @@ #include -#include +#include // ASSERT_POSTCONDITION using namespace bluevk; @@ -47,24 +47,29 @@ static void clampToFramebuffer(VkRect2D* rect, uint32_t fbWidth, uint32_t fbHeig rect->extent.height = std::max(top - y, 0); } -VulkanProgram::VulkanProgram(VkDevice device, Program& builder) noexcept +VulkanProgram::VulkanProgram(VkDevice device, Program const& builder) noexcept : HwProgram(builder.getName()), VulkanResource(VulkanResourceType::PROGRAM), mInfo(new PipelineInfo()), mDevice(device) { - Program::ShaderSource& blobs = builder.getShadersSource(); + Program::ShaderSource const& blobs = builder.getShadersSource(); auto& modules = mInfo->shaders; auto const& specializationConstants = builder.getSpecializationConstants(); + std::vector shader; for (size_t i = 0; i < MAX_SHADER_MODULES; i++) { - Program::ShaderBlob& blob = blobs[i]; - - workaroundSpecConstant(blob, specializationConstants); + Program::ShaderBlob const& blob = blobs[i]; uint32_t* data = (uint32_t*) blob.data(); size_t dataSize = blob.size(); + if (!specializationConstants.empty()) { + workaroundSpecConstant(blob, specializationConstants, shader); + data = (uint32_t*) shader.data(); + dataSize = shader.size() * 4; + } + VkShaderModule& module = modules[i]; VkShaderModuleCreateInfo moduleInfo = { .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, diff --git a/filament/backend/src/vulkan/VulkanHandles.h b/filament/backend/src/vulkan/VulkanHandles.h index 043abc05065..34cfda45c33 100644 --- a/filament/backend/src/vulkan/VulkanHandles.h +++ b/filament/backend/src/vulkan/VulkanHandles.h @@ -37,7 +37,7 @@ class VulkanTimestamps; struct VulkanProgram : public HwProgram, VulkanResource { - VulkanProgram(VkDevice device, Program& builder) noexcept; + VulkanProgram(VkDevice device, Program const& builder) noexcept; struct CustomSamplerInfo { uint8_t groupIndex; diff --git a/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp index a72c0e8698e..3a84d1b6390 100644 --- a/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp +++ b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.cpp @@ -16,22 +16,22 @@ #include "VulkanSpirvUtils.h" -#include +#include // UTILS_UNUSED_IN_RELEASE, UTILS_FALLTHROUGH +#include // assert_invariant +#include -#include #include #include +#include namespace filament::backend { -using namespace bluevk; - namespace { // This function transforms an OpSpecConstant instruction into just a OpConstant instruction. // Additionally, it will adjust the value of the constant as given by the program. -void getTransformedConstantInst(SpecConstantValue const& value, uint32_t* inst) { +void getTransformedConstantInst(SpecConstantValue* value, uint32_t* inst) { // The first word is the size of the instruction and the instruction type. // The second word is the type of the instruction. @@ -41,15 +41,25 @@ void getTransformedConstantInst(SpecConstantValue const& value, uint32_t* inst) constexpr size_t const OP = 0; constexpr size_t const VALUE = 3; - if (std::holds_alternative(value)) { + if (!value) { + // If a specialization wasn't provided, just switch the opcode. + uint32_t const op = inst[OP] & 0x0000FFFF; + if (op == spv::Op::OpSpecConstantFalse) { + inst[OP] = (3 << 16) | spv::Op::OpConstantFalse; + } else if (op == spv::Op::OpSpecConstantTrue) { + inst[OP] = (3 << 16) | spv::Op::OpConstantTrue; + } else if (op == spv::Op::OpSpecConstant) { + inst[OP] = (4 << 16) | spv::Op::OpConstant; + } + } else if (std::holds_alternative(*value)) { inst[OP] = (3 << 16) - | (std::get(value) ? spv::Op::OpConstantTrue : spv::Op::OpConstantFalse); - } else if (std::holds_alternative(value)) { - float const fval = std::get(value); + | (std::get(*value) ? spv::Op::OpConstantTrue : spv::Op::OpConstantFalse); + } else if (std::holds_alternative(*value)) { + float const fval = std::get(*value); inst[OP] = (4 << 16) | spv::Op::OpConstant; inst[VALUE] = *reinterpret_cast(&fval); } else { - int const ival = std::get(value); + int const ival = std::get(*value); inst[OP] = (4 << 16) | spv::Op::OpConstant; inst[VALUE] = *reinterpret_cast(&ival); } @@ -57,10 +67,12 @@ void getTransformedConstantInst(SpecConstantValue const& value, uint32_t* inst) } // anonymous namespace -void workaroundSpecConstant(Program::ShaderBlob& blob, - utils::FixedCapacityVector const& specConstants) { +void workaroundSpecConstant(Program::ShaderBlob const& blob, + utils::FixedCapacityVector const& specConstants, + std::vector& output) { using WordMap = std::unordered_map; using SpecValueMap = std::unordered_map; + constexpr size_t const HEADER_SIZE = 5; WordMap varToIdMap; SpecValueMap idToValue; @@ -79,47 +91,58 @@ void workaroundSpecConstant(Program::ShaderBlob& blob, // %1 as the result, we want to change that instruction to just an OpConsant where the constant // value is adjusted by the spec values provided in the program. // Additionally, we will turn the SpecId decorations to no-ops. - uint32_t* outputData = (uint32_t*) blob.data(); + size_t const dataSize = blob.size() / 4; + + output.resize(dataSize); + uint32_t const* data = (uint32_t*) blob.data(); + uint32_t* outputData = output.data(); + + std::memcpy(&outputData[0], &data[0], HEADER_SIZE * 4); + size_t outputCursor = HEADER_SIZE; - for (uint32_t cursor = 5, cursorEnd = blob.size() / 4; cursor < cursorEnd;) { - uint32_t const firstWord = outputData[cursor]; + for (uint32_t cursor = HEADER_SIZE, cursorEnd = dataSize; cursor < cursorEnd;) { + uint32_t const firstWord = data[cursor]; uint32_t const wordCount = firstWord >> 16; uint32_t const op = firstWord & 0x0000FFFF; switch(op) { - case spv::Op::OpDecorate: { - if (outputData[cursor + 2] == spv::Decoration::DecorationSpecId) { - uint32_t const targetVar = outputData[cursor + 1]; - uint32_t const specId = outputData[cursor + 3]; - varToIdMap[targetVar] = specId; - // Now we write noops over the decoration since its no longer needed. - for (size_t i = cursor, n = cursor + wordCount; i < n; ++i) { - outputData[i] = (1 << 16) | spv::Op::OpNop; - } - } - break; - } case spv::Op::OpSpecConstant: case spv::Op::OpSpecConstantTrue: case spv::Op::OpSpecConstantFalse: { - uint32_t const targetVar = outputData[cursor + 2]; + uint32_t const targetVar = data[cursor + 2]; UTILS_UNUSED_IN_RELEASE WordMap::const_iterator idItr = varToIdMap.find(targetVar); assert_invariant(idItr != varToIdMap.end() && "Cannot find variable previously decorated with SpecId"); - assert_invariant(idToValue.find(idItr->second) != idToValue.end() && - "Spec constant value not provided"); + auto valItr = idToValue.find(idItr->second); - auto const& val = idToValue[varToIdMap[targetVar]]; - getTransformedConstantInst(val, &outputData[cursor]); + SpecConstantValue* val = (valItr != idToValue.end()) ? &valItr->second : nullptr; + std::memcpy(&outputData[outputCursor], &data[cursor], wordCount * 4); + getTransformedConstantInst(val, &outputData[outputCursor]); + outputCursor += wordCount; break; } + case spv::Op::OpDecorate: { + if (data[cursor + 2] == spv::Decoration::DecorationSpecId) { + uint32_t const targetVar = data[cursor + 1]; + uint32_t const specId = data[cursor + 3]; + varToIdMap[targetVar] = specId; + + // Note these decorations do not need to be written to the output. + break; + } + // else fallthrough and copy like all other instructions + UTILS_FALLTHROUGH; + } default: + std::memcpy(&outputData[outputCursor], &data[cursor], wordCount * 4); + outputCursor += wordCount; break; } cursor += wordCount; } + output.resize(outputCursor); } } // namespace filament::backend diff --git a/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h index 8251ba3856b..ebbb11af666 100644 --- a/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h +++ b/filament/backend/src/vulkan/spirv/VulkanSpirvUtils.h @@ -28,15 +28,19 @@ namespace filament::backend { using SpecConstantValue = Program::SpecializationConstant::Type; // For certain drivers, using spec constant can lead to compile errors [1] or undesirable behaviors -// [2]. In those instances, we simply change the spirv and set them to constants. This function will -// modify the blob (but it's safe to do so since blobs are "moved" to the backend). +// [2]. In those instances, we simply change the spirv and set them to constants. +// +// (Implemenation note: we cannot write to the blob because spirv-validator does not properly handle +// the Nop (no-op) instruction, and swiftshader validates the shader before compilation. So we need +// to skip those instructions instead). // // [1]: QC driver cannot use spec constant to size fields // (https://github.com/google/filament/issues/6444). // [2]: An internal driver does not DCE a block guarded by a spec-const boolean set to false // (b/310603393). -void workaroundSpecConstant(Program::ShaderBlob& blob, - utils::FixedCapacityVector const& specConstants); +void workaroundSpecConstant(Program::ShaderBlob const& blob, + utils::FixedCapacityVector const& specConstants, + std::vector& output); } // namespace filament::backend From ebaee14b8b78c05c1278e6dad9ce28250a3485f2 Mon Sep 17 00:00:00 2001 From: Eliza Velasquez Date: Wed, 6 Dec 2023 17:09:53 -0800 Subject: [PATCH 17/20] Generate dummy skinning variants for FL0 mats Even if skinning is not fully implemented on FL0, we have clients which depend on materials with skinning variants that otherwise could easily be converted to FL0 materials. There are two proper ways to deal with this: 1. Support skinning/morphing in Feature Level 0. 2. Allow ESSL 1.0 code and ESSL 3.0 code to support different sets of variants. However, the simplest solution is to just include skinning/morphing variants, but disable codegen for ESSL 1.0 code, making them identical to the base variants. This shouldn't increase the file size much due to the dictionary deflation. Of course, skinning will not work correctly on FL0, but this has always been the case. Future work here would be to properly implement one of the two solutions described above. --- NEW_RELEASE_NOTES.md | 1 + libs/filamat/src/MaterialBuilder.cpp | 1 - libs/filamat/src/shaders/ShaderGenerator.cpp | 16 +++++++++++++--- libs/filamat/src/shaders/ShaderGenerator.h | 4 ++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index c3161a7700b..66bcacba424 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -8,3 +8,4 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut +- matc: Generate skinning variants for FL0 materials [⚠️ **Recompile materials**] diff --git a/libs/filamat/src/MaterialBuilder.cpp b/libs/filamat/src/MaterialBuilder.cpp index 050dd3ebde6..4a04aa63144 100644 --- a/libs/filamat/src/MaterialBuilder.cpp +++ b/libs/filamat/src/MaterialBuilder.cpp @@ -1163,7 +1163,6 @@ Package MaterialBuilder::build(JobSystem& jobSystem) noexcept { mVariantFilter |= uint32_t(UserVariantFilterBit::DIRECTIONAL_LIGHTING); mVariantFilter |= uint32_t(UserVariantFilterBit::DYNAMIC_LIGHTING); mVariantFilter |= uint32_t(UserVariantFilterBit::SHADOW_RECEIVER); - mVariantFilter |= uint32_t(UserVariantFilterBit::SKINNING); mVariantFilter |= uint32_t(UserVariantFilterBit::VSM); mVariantFilter |= uint32_t(UserVariantFilterBit::SSR); mVariantFilter |= uint32_t(UserVariantFilterBit::STE); diff --git a/libs/filamat/src/shaders/ShaderGenerator.cpp b/libs/filamat/src/shaders/ShaderGenerator.cpp index e1516be1436..5b3a0b1cbce 100644 --- a/libs/filamat/src/shaders/ShaderGenerator.cpp +++ b/libs/filamat/src/shaders/ShaderGenerator.cpp @@ -23,6 +23,7 @@ #include +#include "backend/DriverEnums.h" #include "filamat/MaterialBuilder.h" #include "CodeGenerator.h" #include "SibGenerator.h" @@ -56,7 +57,7 @@ void ShaderGenerator::generateSurfaceMaterialVariantDefines(utils::io::sstream& switch (stage) { case ShaderStage::VERTEX: CodeGenerator::generateDefine(out, "VARIANT_HAS_SKINNING_OR_MORPHING", - variant.hasSkinningOrMorphing()); + hasSkinningOrMorphing(variant, featureLevel)); break; case ShaderStage::FRAGMENT: CodeGenerator::generateDefine(out, "VARIANT_HAS_FOG", @@ -397,7 +398,7 @@ std::string ShaderGenerator::createVertexProgram(ShaderModel shaderModel, generateSurfaceMaterialVariantProperties(vs, mProperties, mDefines); AttributeBitset attributes = material.requiredAttributes; - if (variant.hasSkinningOrMorphing()) { + if (hasSkinningOrMorphing(variant, featureLevel)) { attributes.set(VertexAttribute::BONE_INDICES); attributes.set(VertexAttribute::BONE_WEIGHTS); if (material.useLegacyMorphing) { @@ -437,7 +438,7 @@ std::string ShaderGenerator::createVertexProgram(ShaderModel shaderModel, UniformBindingPoints::SHADOW, UibGenerator::getShadowUib()); } - if (variant.hasSkinningOrMorphing()) { + if (hasSkinningOrMorphing(variant, featureLevel)) { cg.generateUniforms(vs, ShaderStage::VERTEX, UniformBindingPoints::PER_RENDERABLE_BONES, UibGenerator::getPerRenderableBonesUib()); @@ -748,4 +749,13 @@ std::string ShaderGenerator::createPostProcessFragmentProgram(ShaderModel sm, return fs.c_str(); } +bool ShaderGenerator::hasSkinningOrMorphing( + filament::Variant variant, MaterialBuilder::FeatureLevel featureLevel) noexcept { + return variant.hasSkinningOrMorphing() + // HACK(exv): Ignore skinning/morphing variant when targeting ESSL 1.0. We should + // either properly support skinning on FL0 or build a system in matc which allows + // the set of included variants to differ per-feature level. + && featureLevel > MaterialBuilder::FeatureLevel::FEATURE_LEVEL_0; +} + } // namespace filament diff --git a/libs/filamat/src/shaders/ShaderGenerator.h b/libs/filamat/src/shaders/ShaderGenerator.h index 985fd63a017..83edb71a179 100644 --- a/libs/filamat/src/shaders/ShaderGenerator.h +++ b/libs/filamat/src/shaders/ShaderGenerator.h @@ -111,6 +111,10 @@ class ShaderGenerator { static void appendShader(utils::io::sstream& ss, const utils::CString& shader, size_t lineOffset) noexcept; + static bool hasSkinningOrMorphing( + filament::Variant variant, + MaterialBuilder::FeatureLevel featureLevel) noexcept; + MaterialBuilder::PropertyList mProperties; MaterialBuilder::VariableList mVariables; MaterialBuilder::OutputList mOutputs; From e1beabaa989e13ca555037af137038aec1d19ed9 Mon Sep 17 00:00:00 2001 From: Benjamin Doherty Date: Sun, 10 Dec 2023 19:43:28 -0800 Subject: [PATCH 18/20] Bump MATERIAL_VERSION to 49 --- libs/filabridge/include/filament/MaterialEnums.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/filabridge/include/filament/MaterialEnums.h b/libs/filabridge/include/filament/MaterialEnums.h index 6a74ac7e3a9..5e16552bb63 100644 --- a/libs/filabridge/include/filament/MaterialEnums.h +++ b/libs/filabridge/include/filament/MaterialEnums.h @@ -28,7 +28,7 @@ namespace filament { // update this when a new version of filament wouldn't work with older materials -static constexpr size_t MATERIAL_VERSION = 48; +static constexpr size_t MATERIAL_VERSION = 49; /** * Supported shading models From 72765a5b0ac1ef939728019abd9a2af41cc9b8dc Mon Sep 17 00:00:00 2001 From: Benjamin Doherty Date: Sun, 10 Dec 2023 19:52:39 -0800 Subject: [PATCH 19/20] Fix bump-version script on Darwin --- build/common/bump-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common/bump-version.sh b/build/common/bump-version.sh index 9613a764ff6..f8c11d935d9 100755 --- a/build/common/bump-version.sh +++ b/build/common/bump-version.sh @@ -50,7 +50,7 @@ function replace { FIND_STR="${1//\{\{VERSION\}\}/${VERSION_REGEX}}" REPLACE_STR="${1//\{\{VERSION\}\}/${NEW_VERSION}}" local FILE_NAME="$2" - if [ IS_DARWIN == 1 ]; then + if [ $IS_DARWIN == 1 ]; then sed -i '' -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}" else sed -i -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}" From a1de8c924d0b13f84a065773089a304d539ba539 Mon Sep 17 00:00:00 2001 From: Benjamin Doherty Date: Mon, 11 Dec 2023 00:09:20 -0800 Subject: [PATCH 20/20] Update RELEASE_NOTES --- NEW_RELEASE_NOTES.md | 1 - RELEASE_NOTES.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index 66bcacba424..c3161a7700b 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -8,4 +8,3 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut -- matc: Generate skinning variants for FL0 materials [⚠️ **Recompile materials**] diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6b9ce2dd219..56bfa41ea6e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,6 +10,7 @@ Instead, if you are authoring a PR for the main branch, add your release note to ## v1.49.0 - matc: Fix ESSL 1.0 codegen when using external samplers [⚠️ **Recompile materials**] +- matc: Generate skinning variants for FL0 materials [⚠️ **Recompile materials**] ## v1.48.0