diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h index 74cd318de..dd0669fcb 100644 --- a/include/GLSLANG/ShaderLang.h +++ b/include/GLSLANG/ShaderLang.h @@ -26,7 +26,7 @@ // Version number for shader translation API. // It is incremented every time the API changes. -#define ANGLE_SH_VERSION 305 +#define ANGLE_SH_VERSION 306 enum ShShaderSpec { @@ -79,11 +79,20 @@ enum ShShaderOutput SH_MSL_METAL_OUTPUT = 0x8B4D, }; +// For ANGLE_shader_pixel_local_storage. +// Instructs the compiler which pixel local storage configuration to generate code for. +enum class ShPixelLocalStorageType +{ + NotSupported, + ImageStoreR32PackedFormats, + ImageStoreNativeFormats, +}; + // For ANGLE_shader_pixel_local_storage_coherent. // Instructs the compiler which fragment synchronization method to use, if any. enum class ShFragmentSynchronizationType { - NoSynchronization, + NotSupported, FragmentShaderInterlock_NV_GL, FragmentShaderOrdering_INTEL_GL, @@ -110,8 +119,10 @@ struct ShCompileOptionsMetal struct ShCompileOptionsPLS { + ShPixelLocalStorageType type = ShPixelLocalStorageType::NotSupported; // For ANGLE_shader_pixel_local_storage_coherent. - ShFragmentSynchronizationType fragmentSynchronizationType; + ShFragmentSynchronizationType fragmentSynchronizationType = + ShFragmentSynchronizationType::NotSupported; }; struct ShCompileOptions diff --git a/src/compiler/translator/tree_ops/RewritePixelLocalStorage.cpp b/src/compiler/translator/tree_ops/RewritePixelLocalStorage.cpp index 2f6c41122..34bc2d367 100644 --- a/src/compiler/translator/tree_ops/RewritePixelLocalStorage.cpp +++ b/src/compiler/translator/tree_ops/RewritePixelLocalStorage.cpp @@ -105,12 +105,10 @@ static TIntermNode *CreateBuiltInInterlockEndCall(const ShCompileOptions &compil class RewriteToImagesTraverser : public TIntermTraverser { public: - RewriteToImagesTraverser(TCompiler *compiler, - TSymbolTable &symbolTable, + RewriteToImagesTraverser(TSymbolTable &symbolTable, const ShCompileOptions &compileOptions, int shaderVersion) : TIntermTraverser(true, false, false, &symbolTable), - mCompiler(compiler), mCompileOptions(&compileOptions), mShaderVersion(shaderVersion) {} @@ -230,10 +228,7 @@ class RewriteToImagesTraverser : public TIntermTraverser // Do all PLS formats need to be packed into r32f, r32i, or r32ui image2Ds? bool needsR32Packing() const { - // ES images can only have both read and write access if their format is r32f, r32i, r32ui. - // D3D 11.0 UAVs only support R32_FLOAT, R32_UINT, R32_SINT formats. - return mCompiler->getOutputType() == ShShaderOutput::SH_ESSL_OUTPUT || - mCompiler->getOutputType() == ShShaderOutput::SH_HLSL_4_1_OUTPUT; + return mCompileOptions->pls.type == ShPixelLocalStorageType::ImageStoreR32PackedFormats; } // Sets the given image2D as the backing storage for the plsSymbol's binding point. An entry @@ -482,7 +477,6 @@ class RewriteToImagesTraverser : public TIntermTraverser return TIntermAggregate::CreateConstructor(imageStoreType, {result}); } - const TCompiler *const mCompiler; const ShCompileOptions *const mCompileOptions; const int mShaderVersion; @@ -533,7 +527,7 @@ bool RewritePixelLocalStorageToImages(TCompiler *compiler, } // Rewrite PLS operations to image operations. - RewriteToImagesTraverser traverser(compiler, symbolTable, compileOptions, shaderVersion); + RewriteToImagesTraverser traverser(symbolTable, compileOptions, shaderVersion); root->traverse(&traverser); if (!traverser.updateTree(compiler, root)) { diff --git a/src/libANGLE/renderer/ContextImpl.h b/src/libANGLE/renderer/ContextImpl.h index 608aa9afa..3b167fe8b 100644 --- a/src/libANGLE/renderer/ContextImpl.h +++ b/src/libANGLE/renderer/ContextImpl.h @@ -212,10 +212,11 @@ class ContextImpl : public GLImplFactory virtual angle::Result onUnMakeCurrent(const gl::Context *context); // Native capabilities, unmodified by gl::Context. - virtual gl::Caps getNativeCaps() const = 0; - virtual const gl::TextureCapsMap &getNativeTextureCaps() const = 0; - virtual const gl::Extensions &getNativeExtensions() const = 0; - virtual const gl::Limitations &getNativeLimitations() const = 0; + virtual gl::Caps getNativeCaps() const = 0; + virtual const gl::TextureCapsMap &getNativeTextureCaps() const = 0; + virtual const gl::Extensions &getNativeExtensions() const = 0; + virtual const gl::Limitations &getNativeLimitations() const = 0; + virtual ShPixelLocalStorageType getNativePixelLocalStorageType() const = 0; virtual angle::Result dispatchCompute(const gl::Context *context, GLuint numGroupsX, diff --git a/src/libANGLE/renderer/d3d/RendererD3D.cpp b/src/libANGLE/renderer/d3d/RendererD3D.cpp index edea121fb..39e6e536d 100644 --- a/src/libANGLE/renderer/d3d/RendererD3D.cpp +++ b/src/libANGLE/renderer/d3d/RendererD3D.cpp @@ -152,6 +152,16 @@ const gl::Limitations &RendererD3D::getNativeLimitations() const return mNativeLimitations; } +ShPixelLocalStorageType RendererD3D::getNativePixelLocalStorageType() const +{ + if (!getNativeExtensions().shaderPixelLocalStorageANGLE) + { + return ShPixelLocalStorageType::NotSupported; + } + // Read/write UAVs only support "r32*" images. + return ShPixelLocalStorageType::ImageStoreR32PackedFormats; +} + Serial RendererD3D::generateSerial() { return mSerialFactory.generate(); diff --git a/src/libANGLE/renderer/d3d/RendererD3D.h b/src/libANGLE/renderer/d3d/RendererD3D.h index cdb57ea8f..3846e1eb2 100644 --- a/src/libANGLE/renderer/d3d/RendererD3D.h +++ b/src/libANGLE/renderer/d3d/RendererD3D.h @@ -424,6 +424,7 @@ class RendererD3D : public BufferFactoryD3D const gl::TextureCapsMap &getNativeTextureCaps() const; const gl::Extensions &getNativeExtensions() const; const gl::Limitations &getNativeLimitations() const; + ShPixelLocalStorageType getNativePixelLocalStorageType() const; virtual void initializeFrontendFeatures(angle::FrontendFeatures *features) const = 0; // Necessary hack for default framebuffers in D3D. diff --git a/src/libANGLE/renderer/d3d/ShaderD3D.cpp b/src/libANGLE/renderer/d3d/ShaderD3D.cpp index 8ada8f5f6..e08e478ae 100644 --- a/src/libANGLE/renderer/d3d/ShaderD3D.cpp +++ b/src/libANGLE/renderer/d3d/ShaderD3D.cpp @@ -15,6 +15,7 @@ #include "libANGLE/Context.h" #include "libANGLE/Shader.h" #include "libANGLE/features.h" +#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/d3d/ProgramD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/trace.h" @@ -286,10 +287,14 @@ std::shared_ptr ShaderD3D::compile(const gl::Context *cont { options->initializeBuiltinsForInstancedMultiview = true; } - if (extensions.shaderPixelLocalStorageCoherentANGLE) + if (extensions.shaderPixelLocalStorageANGLE) { - options->pls.fragmentSynchronizationType = - ShFragmentSynchronizationType::RasterizerOrderViews_D3D; + options->pls.type = mRenderer->getNativePixelLocalStorageType(); + if (extensions.shaderPixelLocalStorageCoherentANGLE) + { + options->pls.fragmentSynchronizationType = + ShFragmentSynchronizationType::RasterizerOrderViews_D3D; + } } auto postTranslateFunctor = [this](gl::ShCompilerInstance *compiler, std::string *infoLog) { diff --git a/src/libANGLE/renderer/d3d/d3d11/Context11.cpp b/src/libANGLE/renderer/d3d/d3d11/Context11.cpp index 3ccebf070..4c4b3ca39 100644 --- a/src/libANGLE/renderer/d3d/d3d11/Context11.cpp +++ b/src/libANGLE/renderer/d3d/d3d11/Context11.cpp @@ -861,6 +861,11 @@ const gl::Limitations &Context11::getNativeLimitations() const return mRenderer->getNativeLimitations(); } +ShPixelLocalStorageType Context11::getNativePixelLocalStorageType() const +{ + return mRenderer->getNativePixelLocalStorageType(); +} + angle::Result Context11::dispatchCompute(const gl::Context *context, GLuint numGroupsX, GLuint numGroupsY, diff --git a/src/libANGLE/renderer/d3d/d3d11/Context11.h b/src/libANGLE/renderer/d3d/d3d11/Context11.h index 90fd4fa0f..5f84e410b 100644 --- a/src/libANGLE/renderer/d3d/d3d11/Context11.h +++ b/src/libANGLE/renderer/d3d/d3d11/Context11.h @@ -232,6 +232,7 @@ class Context11 : public ContextD3D, public MultisampleTextureInitializer const gl::TextureCapsMap &getNativeTextureCaps() const override; const gl::Extensions &getNativeExtensions() const override; const gl::Limitations &getNativeLimitations() const override; + ShPixelLocalStorageType getNativePixelLocalStorageType() const override; Renderer11 *getRenderer() const { return mRenderer; } diff --git a/src/libANGLE/renderer/d3d/d3d9/Context9.cpp b/src/libANGLE/renderer/d3d/d3d9/Context9.cpp index a4981ccd3..5f624e815 100644 --- a/src/libANGLE/renderer/d3d/d3d9/Context9.cpp +++ b/src/libANGLE/renderer/d3d/d3d9/Context9.cpp @@ -466,6 +466,11 @@ const gl::Limitations &Context9::getNativeLimitations() const return mRenderer->getNativeLimitations(); } +ShPixelLocalStorageType Context9::getNativePixelLocalStorageType() const +{ + return mRenderer->getNativePixelLocalStorageType(); +} + angle::Result Context9::dispatchCompute(const gl::Context *context, GLuint numGroupsX, GLuint numGroupsY, diff --git a/src/libANGLE/renderer/d3d/d3d9/Context9.h b/src/libANGLE/renderer/d3d/d3d9/Context9.h index 806569b12..ce3e93029 100644 --- a/src/libANGLE/renderer/d3d/d3d9/Context9.h +++ b/src/libANGLE/renderer/d3d/d3d9/Context9.h @@ -231,6 +231,7 @@ class Context9 : public ContextD3D const gl::TextureCapsMap &getNativeTextureCaps() const override; const gl::Extensions &getNativeExtensions() const override; const gl::Limitations &getNativeLimitations() const override; + ShPixelLocalStorageType getNativePixelLocalStorageType() const override; angle::Result dispatchCompute(const gl::Context *context, GLuint numGroupsX, diff --git a/src/libANGLE/renderer/gl/ContextGL.cpp b/src/libANGLE/renderer/gl/ContextGL.cpp index 5895746c7..4979a6ff4 100644 --- a/src/libANGLE/renderer/gl/ContextGL.cpp +++ b/src/libANGLE/renderer/gl/ContextGL.cpp @@ -935,6 +935,11 @@ const gl::Limitations &ContextGL::getNativeLimitations() const return mRenderer->getNativeLimitations(); } +ShPixelLocalStorageType ContextGL::getNativePixelLocalStorageType() const +{ + return mRenderer->getNativePixelLocalStorageType(); +} + StateManagerGL *ContextGL::getStateManager() { return mRenderer->getStateManager(); diff --git a/src/libANGLE/renderer/gl/ContextGL.h b/src/libANGLE/renderer/gl/ContextGL.h index 1eefe4e62..6916662f7 100644 --- a/src/libANGLE/renderer/gl/ContextGL.h +++ b/src/libANGLE/renderer/gl/ContextGL.h @@ -254,6 +254,7 @@ class ContextGL : public ContextImpl const gl::TextureCapsMap &getNativeTextureCaps() const override; const gl::Extensions &getNativeExtensions() const override; const gl::Limitations &getNativeLimitations() const override; + ShPixelLocalStorageType getNativePixelLocalStorageType() const override; // Handle helpers ANGLE_INLINE const FunctionsGL *getFunctions() const { return mRenderer->getFunctions(); } diff --git a/src/libANGLE/renderer/gl/RendererGL.cpp b/src/libANGLE/renderer/gl/RendererGL.cpp index 061ff554d..6b60a06e0 100644 --- a/src/libANGLE/renderer/gl/RendererGL.cpp +++ b/src/libANGLE/renderer/gl/RendererGL.cpp @@ -331,6 +331,18 @@ const gl::Limitations &RendererGL::getNativeLimitations() const return mNativeLimitations; } +ShPixelLocalStorageType RendererGL::getNativePixelLocalStorageType() const +{ + if (!getNativeExtensions().shaderPixelLocalStorageANGLE) + { + return ShPixelLocalStorageType::NotSupported; + } + // OpenGL ES only allows read/write access to "r32*" images. + return getFunctions()->standard == StandardGL::STANDARD_GL_ES + ? ShPixelLocalStorageType::ImageStoreR32PackedFormats + : ShPixelLocalStorageType::ImageStoreNativeFormats; +} + MultiviewImplementationTypeGL RendererGL::getMultiviewImplementationType() const { ensureCapsInitialized(); diff --git a/src/libANGLE/renderer/gl/RendererGL.h b/src/libANGLE/renderer/gl/RendererGL.h index 4b2d469ab..d2a4ed970 100644 --- a/src/libANGLE/renderer/gl/RendererGL.h +++ b/src/libANGLE/renderer/gl/RendererGL.h @@ -111,6 +111,7 @@ class RendererGL : angle::NonCopyable const gl::TextureCapsMap &getNativeTextureCaps() const; const gl::Extensions &getNativeExtensions() const; const gl::Limitations &getNativeLimitations() const; + ShPixelLocalStorageType getNativePixelLocalStorageType() const; void initializeFrontendFeatures(angle::FrontendFeatures *features) const; angle::Result dispatchCompute(const gl::Context *context, diff --git a/src/libANGLE/renderer/gl/ShaderGL.cpp b/src/libANGLE/renderer/gl/ShaderGL.cpp index bdde4e18b..67c35298c 100644 --- a/src/libANGLE/renderer/gl/ShaderGL.cpp +++ b/src/libANGLE/renderer/gl/ShaderGL.cpp @@ -11,6 +11,7 @@ #include "common/debug.h" #include "libANGLE/Compiler.h" #include "libANGLE/Context.h" +#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/RendererGL.h" #include "libANGLE/trace.h" @@ -375,39 +376,42 @@ std::shared_ptr ShaderGL::compile(const gl::Context *conte options->passHighpToPackUnormSnormBuiltins = true; } - if (mRenderer->getNativeExtensions().shaderPixelLocalStorageCoherentANGLE) + if (mRenderer->getNativeExtensions().shaderPixelLocalStorageANGLE) { - const ShShaderOutput translatorOutputType = GetShaderOutputType(GetFunctionsGL(context)); - - // Prefer vendor-specific extensions first. The PixelLocalStorageTest.Coherency test doesn't - // always pass on Intel when we use the ARB extension. - if (features.supportsFragmentShaderInterlockNV.enabled) + options->pls.type = mRenderer->getNativePixelLocalStorageType(); + if (mRenderer->getNativeExtensions().shaderPixelLocalStorageCoherentANGLE) { - // This extension requires 430+. GetShaderOutputType() should always select 430+ on a GL - // 4.3 context, where this extension is defined. - ASSERT(mRenderer->getFunctions()->isAtLeastGL(gl::Version(4, 3))); - ASSERT(translatorOutputType >= SH_GLSL_430_CORE_OUTPUT); - options->pls.fragmentSynchronizationType = - ShFragmentSynchronizationType::FragmentShaderInterlock_NV_GL; - } - else if (features.supportsFragmentShaderOrderingINTEL.enabled) - { - // This extension requires 440+. GetShaderOutputType() should always select 440+ on a GL - // 4.4 context, where this extension is defined. - ASSERT(mRenderer->getFunctions()->isAtLeastGL(gl::Version(4, 4))); - ASSERT(translatorOutputType >= SH_GLSL_440_CORE_OUTPUT); - options->pls.fragmentSynchronizationType = - ShFragmentSynchronizationType::FragmentShaderOrdering_INTEL_GL; - } - else - { - ASSERT(features.supportsFragmentShaderInterlockARB.enabled); - // This extension requires 450+. GetShaderOutputType() should always select 450+ on a GL - // 4.5 context, where this extension is defined. - ASSERT(mRenderer->getFunctions()->isAtLeastGL(gl::Version(4, 5))); - ASSERT(translatorOutputType >= SH_GLSL_450_CORE_OUTPUT); - options->pls.fragmentSynchronizationType = - ShFragmentSynchronizationType::FragmentShaderInterlock_ARB_GL; + // Prefer vendor-specific extensions first. The PixelLocalStorageTest.Coherency test + // doesn't always pass on Intel when we use the ARB extension. + ShShaderOutput translatorOutputType = GetShaderOutputType(GetFunctionsGL(context)); + if (features.supportsFragmentShaderInterlockNV.enabled) + { + // This extension requires 430+. GetShaderOutputType() should always select 430+ on + // a GL 4.3 context, where this extension is defined. + ASSERT(mRenderer->getFunctions()->isAtLeastGL(gl::Version(4, 3))); + ASSERT(translatorOutputType >= SH_GLSL_430_CORE_OUTPUT); + options->pls.fragmentSynchronizationType = + ShFragmentSynchronizationType::FragmentShaderInterlock_NV_GL; + } + else if (features.supportsFragmentShaderOrderingINTEL.enabled) + { + // This extension requires 440+. GetShaderOutputType() should always select 440+ on + // a GL 4.4 context, where this extension is defined. + ASSERT(mRenderer->getFunctions()->isAtLeastGL(gl::Version(4, 4))); + ASSERT(translatorOutputType >= SH_GLSL_440_CORE_OUTPUT); + options->pls.fragmentSynchronizationType = + ShFragmentSynchronizationType::FragmentShaderOrdering_INTEL_GL; + } + else + { + ASSERT(features.supportsFragmentShaderInterlockARB.enabled); + // This extension requires 450+. GetShaderOutputType() should always select 450+ on + // a GL 4.5 context, where this extension is defined. + ASSERT(mRenderer->getFunctions()->isAtLeastGL(gl::Version(4, 5))); + ASSERT(translatorOutputType >= SH_GLSL_450_CORE_OUTPUT); + options->pls.fragmentSynchronizationType = + ShFragmentSynchronizationType::FragmentShaderInterlock_ARB_GL; + } } } diff --git a/src/libANGLE/renderer/metal/ContextMtl.h b/src/libANGLE/renderer/metal/ContextMtl.h index 67e137dc2..e437eab39 100644 --- a/src/libANGLE/renderer/metal/ContextMtl.h +++ b/src/libANGLE/renderer/metal/ContextMtl.h @@ -207,6 +207,7 @@ class ContextMtl : public ContextImpl, public mtl::Context const gl::TextureCapsMap &getNativeTextureCaps() const override; const gl::Extensions &getNativeExtensions() const override; const gl::Limitations &getNativeLimitations() const override; + ShPixelLocalStorageType getNativePixelLocalStorageType() const override; const ProgramMtl *getProgram() const { return mProgram; } diff --git a/src/libANGLE/renderer/metal/ContextMtl.mm b/src/libANGLE/renderer/metal/ContextMtl.mm index 23c1fba71..6ce2331e4 100644 --- a/src/libANGLE/renderer/metal/ContextMtl.mm +++ b/src/libANGLE/renderer/metal/ContextMtl.mm @@ -1384,6 +1384,10 @@ const gl::Limitations &ContextMtl::getNativeLimitations() const { return getDisplay()->getNativeLimitations(); } +ShPixelLocalStorageType ContextMtl::getNativePixelLocalStorageType() const +{ + return getDisplay()->getNativePixelLocalStorageType(); +} // Shader creation CompilerImpl *ContextMtl::createCompiler() diff --git a/src/libANGLE/renderer/metal/DisplayMtl.h b/src/libANGLE/renderer/metal/DisplayMtl.h index 3a657ddd7..aa0327b6d 100644 --- a/src/libANGLE/renderer/metal/DisplayMtl.h +++ b/src/libANGLE/renderer/metal/DisplayMtl.h @@ -120,6 +120,7 @@ class DisplayMtl : public DisplayImpl const gl::TextureCapsMap &getNativeTextureCaps() const; const gl::Extensions &getNativeExtensions() const; const gl::Limitations &getNativeLimitations() const; + ShPixelLocalStorageType getNativePixelLocalStorageType() const; const angle::FeaturesMtl &getFeatures() const { return mFeatures; } // Check whether either of the specified iOS or Mac GPU family is supported diff --git a/src/libANGLE/renderer/metal/DisplayMtl.mm b/src/libANGLE/renderer/metal/DisplayMtl.mm index b91d003f8..c3606ab89 100644 --- a/src/libANGLE/renderer/metal/DisplayMtl.mm +++ b/src/libANGLE/renderer/metal/DisplayMtl.mm @@ -666,12 +666,16 @@ const gl::Extensions &DisplayMtl::getNativeExtensions() const ensureCapsInitialized(); return mNativeExtensions; } - const gl::Limitations &DisplayMtl::getNativeLimitations() const { ensureCapsInitialized(); return mNativeLimitations; } +ShPixelLocalStorageType DisplayMtl::getNativePixelLocalStorageType() const +{ + // PLS isn't supported on Metal yet. + return ShPixelLocalStorageType::NotSupported; +} void DisplayMtl::ensureCapsInitialized() const { diff --git a/src/libANGLE/renderer/null/ContextNULL.cpp b/src/libANGLE/renderer/null/ContextNULL.cpp index f9e1b3ea0..a88250c10 100644 --- a/src/libANGLE/renderer/null/ContextNULL.cpp +++ b/src/libANGLE/renderer/null/ContextNULL.cpp @@ -407,6 +407,13 @@ const gl::Limitations &ContextNULL::getNativeLimitations() const return mLimitations; } +ShPixelLocalStorageType ContextNULL::getNativePixelLocalStorageType() const +{ + return getNativeExtensions().shaderPixelLocalStorageANGLE + ? ShPixelLocalStorageType::ImageStoreNativeFormats + : ShPixelLocalStorageType::NotSupported; +} + CompilerImpl *ContextNULL::createCompiler() { return new CompilerNULL(); diff --git a/src/libANGLE/renderer/null/ContextNULL.h b/src/libANGLE/renderer/null/ContextNULL.h index 630ff33be..204ec0693 100644 --- a/src/libANGLE/renderer/null/ContextNULL.h +++ b/src/libANGLE/renderer/null/ContextNULL.h @@ -201,6 +201,7 @@ class ContextNULL : public ContextImpl const gl::TextureCapsMap &getNativeTextureCaps() const override; const gl::Extensions &getNativeExtensions() const override; const gl::Limitations &getNativeLimitations() const override; + ShPixelLocalStorageType getNativePixelLocalStorageType() const override; // Shader creation CompilerImpl *createCompiler() override; diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp index 1daa2443c..c16b93668 100644 --- a/src/libANGLE/renderer/vulkan/ContextVk.cpp +++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp @@ -5360,6 +5360,11 @@ const gl::Limitations &ContextVk::getNativeLimitations() const return mRenderer->getNativeLimitations(); } +ShPixelLocalStorageType ContextVk::getNativePixelLocalStorageType() const +{ + return mRenderer->getNativePixelLocalStorageType(); +} + CompilerImpl *ContextVk::createCompiler() { return new CompilerVk(); diff --git a/src/libANGLE/renderer/vulkan/ContextVk.h b/src/libANGLE/renderer/vulkan/ContextVk.h index 97ef53020..45e7989ff 100644 --- a/src/libANGLE/renderer/vulkan/ContextVk.h +++ b/src/libANGLE/renderer/vulkan/ContextVk.h @@ -329,6 +329,7 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText const gl::TextureCapsMap &getNativeTextureCaps() const override; const gl::Extensions &getNativeExtensions() const override; const gl::Limitations &getNativeLimitations() const override; + ShPixelLocalStorageType getNativePixelLocalStorageType() const override; // Shader creation CompilerImpl *createCompiler() override; diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp index e9925b361..6f814f1a7 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.cpp +++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp @@ -4005,6 +4005,15 @@ const gl::Limitations &RendererVk::getNativeLimitations() const return mNativeLimitations; } +ShPixelLocalStorageType RendererVk::getNativePixelLocalStorageType() const +{ + if (!getNativeExtensions().shaderPixelLocalStorageANGLE) + { + return ShPixelLocalStorageType::NotSupported; + } + return ShPixelLocalStorageType::ImageStoreNativeFormats; +} + void RendererVk::initializeFrontendFeatures(angle::FrontendFeatures *features) const { bool isSwiftShader = diff --git a/src/libANGLE/renderer/vulkan/RendererVk.h b/src/libANGLE/renderer/vulkan/RendererVk.h index 0d56d85bf..fb96ee9c7 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.h +++ b/src/libANGLE/renderer/vulkan/RendererVk.h @@ -184,6 +184,7 @@ class RendererVk : angle::NonCopyable const gl::TextureCapsMap &getNativeTextureCaps() const; const gl::Extensions &getNativeExtensions() const; const gl::Limitations &getNativeLimitations() const; + ShPixelLocalStorageType getNativePixelLocalStorageType() const; void initializeFrontendFeatures(angle::FrontendFeatures *features) const; uint32_t getQueueFamilyIndex() const { return mCurrentQueueFamilyIndex; } diff --git a/src/libANGLE/renderer/vulkan/ShaderVk.cpp b/src/libANGLE/renderer/vulkan/ShaderVk.cpp index e0926b0ae..87d6f45db 100644 --- a/src/libANGLE/renderer/vulkan/ShaderVk.cpp +++ b/src/libANGLE/renderer/vulkan/ShaderVk.cpp @@ -114,13 +114,17 @@ std::shared_ptr ShaderVk::compile(const gl::Context *conte options->precisionSafeDivision = true; } - if (contextVk->getExtensions().shaderPixelLocalStorageCoherentANGLE) + if (contextVk->getExtensions().shaderPixelLocalStorageANGLE) { - ASSERT(contextVk->getFeatures().supportsFragmentShaderPixelInterlock.enabled); - // GL_ARB_fragment_shader_interlock compiles to SPV_EXT_fragment_shader_interlock in both - // Vulkan GLSL and our own backend. - options->pls.fragmentSynchronizationType = - ShFragmentSynchronizationType::FragmentShaderInterlock_ARB_GL; + options->pls.type = contextVk->getNativePixelLocalStorageType(); + if (contextVk->getExtensions().shaderPixelLocalStorageCoherentANGLE) + { + ASSERT(contextVk->getFeatures().supportsFragmentShaderPixelInterlock.enabled); + // GL_ARB_fragment_shader_interlock compiles to SPV_EXT_fragment_shader_interlock in + // both Vulkan Glslang and our own backend. + options->pls.fragmentSynchronizationType = + ShFragmentSynchronizationType::FragmentShaderInterlock_ARB_GL; + } } return compileImpl(context, compilerInstance, mState.getSource(), options);