зеркало из https://github.com/AvaloniaUI/angle.git
Reland "Add support for GL_CHROMIUM_texture_filtering"
This is a reland of 38780ae392
modulo the
changes to disable VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT, as
this was causing problems. With this landed, the extension will not work
on SwiftShader until we find a way to allow this extension through the
validation layers.
Bug: b/146423360
Bug: b/154620295
Change-Id: Ie09fc507c01a47be3bb227bc78771660170ba5d3
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2199639
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Родитель
cdfc69c7f0
Коммит
4f343f3e4a
|
@ -510,6 +510,11 @@ GL_APICALL void GL_APIENTRY glImportSemaphoreZirconHandleANGLE(GLuint memory,
|
|||
#endif
|
||||
#endif /* GL_ANGLE_semaphore_fuchsia */
|
||||
|
||||
#ifndef GL_CHROMIUM_texture_filtering_hint
|
||||
#define GL_CHROMIUM_texture_filtering_hint
|
||||
#define GL_TEXTURE_FILTERING_HINT_CHROMIUM 0x8AF0
|
||||
#endif /* GL_CHROMIUM_texture_filtering_hint */
|
||||
|
||||
// clang-format on
|
||||
|
||||
#endif // INCLUDE_GLES2_GL2EXT_ANGLE_H_
|
||||
|
|
|
@ -120,6 +120,10 @@ struct FeaturesVk : FeatureSetBase
|
|||
"supports_external_memory_fuchsia", FeatureCategory::VulkanFeatures,
|
||||
"VkDevice supports the VK_FUCHSIA_external_memory extension", &members};
|
||||
|
||||
angle::Feature supportsFilteringPrecision = {
|
||||
"supports_filtering_precision_google", FeatureCategory::VulkanFeatures,
|
||||
"VkDevice supports the VK_GOOGLE_sampler_filtering_precision extension", &members};
|
||||
|
||||
// Whether the VkDevice supports the VK_KHR_external_fence_capabilities extension.
|
||||
Feature supportsExternalFenceCapabilities = {
|
||||
"supports_external_fence_capabilities", FeatureCategory::VulkanFeatures,
|
||||
|
|
|
@ -1005,6 +1005,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
|
|||
map["GL_ANGLE_texture_multisample"] = enableableExtension(&Extensions::textureMultisample);
|
||||
map["GL_ANGLE_multi_draw"] = enableableExtension(&Extensions::multiDraw);
|
||||
map["GL_ANGLE_provoking_vertex"] = enableableExtension(&Extensions::provokingVertex);
|
||||
map["GL_CHROMIUM_texture_filtering_hint"] = enableableExtension(&Extensions::textureFilteringCHROMIUM);
|
||||
map["GL_CHROMIUM_lose_context"] = enableableExtension(&Extensions::loseContextCHROMIUM);
|
||||
map["GL_ANGLE_texture_external_update"] = enableableExtension(&Extensions::textureExternalUpdateANGLE);
|
||||
map["GL_ANGLE_base_vertex_base_instance"] = enableableExtension(&Extensions::baseVertexBaseInstance);
|
||||
|
|
|
@ -588,6 +588,9 @@ struct Extensions
|
|||
// GL_ANGLE_provoking_vertex
|
||||
bool provokingVertex = false;
|
||||
|
||||
// GL_CHROMIUM_texture_filtering_hint
|
||||
bool textureFilteringCHROMIUM = false;
|
||||
|
||||
// GL_CHROMIUM_lose_context
|
||||
bool loseContextCHROMIUM = false;
|
||||
|
||||
|
|
|
@ -4782,6 +4782,9 @@ void Context::hint(GLenum target, GLenum mode)
|
|||
case GL_FOG_HINT:
|
||||
mState.gles1().setHint(target, mode);
|
||||
break;
|
||||
case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
|
||||
mState.setTextureFilteringHint(mode);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return;
|
||||
|
|
|
@ -352,6 +352,7 @@ State::State(const State *shareContextState,
|
|||
mStencilBackRef(0),
|
||||
mLineWidth(0),
|
||||
mGenerateMipmapHint(GL_NONE),
|
||||
mTextureFilteringHint(GL_NONE),
|
||||
mFragmentShaderDerivativeHint(GL_NONE),
|
||||
mBindGeneratesResource(bindGeneratesResource),
|
||||
mClientArraysEnabled(clientArraysEnabled),
|
||||
|
@ -419,6 +420,7 @@ void State::initialize(Context *context)
|
|||
mSampleMaskValues.fill(~GLbitfield(0));
|
||||
|
||||
mGenerateMipmapHint = GL_DONT_CARE;
|
||||
mTextureFilteringHint = GL_DONT_CARE;
|
||||
mFragmentShaderDerivativeHint = GL_DONT_CARE;
|
||||
|
||||
mLineWidth = 1.0f;
|
||||
|
@ -1428,6 +1430,18 @@ void State::setGenerateMipmapHint(GLenum hint)
|
|||
mDirtyBits.set(DIRTY_BIT_EXTENDED);
|
||||
}
|
||||
|
||||
void State::setTextureFilteringHint(GLenum hint)
|
||||
{
|
||||
mTextureFilteringHint = hint;
|
||||
// Note: we don't add a dirty bit for this flag as it's not expected to be toggled at
|
||||
// runtime.
|
||||
}
|
||||
|
||||
GLenum State::getTextureFilteringHint() const
|
||||
{
|
||||
return mTextureFilteringHint;
|
||||
}
|
||||
|
||||
void State::setFragmentShaderDerivativeHint(GLenum hint)
|
||||
{
|
||||
mFragmentShaderDerivativeHint = hint;
|
||||
|
@ -2477,6 +2491,9 @@ angle::Result State::getIntegerv(const Context *context, GLenum pname, GLint *pa
|
|||
case GL_GENERATE_MIPMAP_HINT:
|
||||
*params = mGenerateMipmapHint;
|
||||
break;
|
||||
case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
|
||||
*params = mTextureFilteringHint;
|
||||
break;
|
||||
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
|
||||
*params = mFragmentShaderDerivativeHint;
|
||||
break;
|
||||
|
|
|
@ -255,6 +255,8 @@ class State : angle::NonCopyable
|
|||
|
||||
// Hint setters
|
||||
void setGenerateMipmapHint(GLenum hint);
|
||||
void setTextureFilteringHint(GLenum hint);
|
||||
GLenum getTextureFilteringHint() const;
|
||||
void setFragmentShaderDerivativeHint(GLenum hint);
|
||||
|
||||
// GL_CHROMIUM_bind_generates_resource
|
||||
|
@ -895,6 +897,7 @@ class State : angle::NonCopyable
|
|||
GLfloat mLineWidth;
|
||||
|
||||
GLenum mGenerateMipmapHint;
|
||||
GLenum mTextureFilteringHint;
|
||||
GLenum mFragmentShaderDerivativeHint;
|
||||
|
||||
const bool mBindGeneratesResource;
|
||||
|
|
|
@ -2979,6 +2979,7 @@ bool GetQueryParameterInfo(const State &glState,
|
|||
case GL_PACK_ALIGNMENT:
|
||||
case GL_UNPACK_ALIGNMENT:
|
||||
case GL_GENERATE_MIPMAP_HINT:
|
||||
case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
|
||||
case GL_RED_BITS:
|
||||
case GL_GREEN_BITS:
|
||||
case GL_BLUE_BITS:
|
||||
|
|
|
@ -87,6 +87,7 @@ _vulkan_backend_sources = [
|
|||
"vk_format_table_autogen.cpp",
|
||||
"vk_format_utils.cpp",
|
||||
"vk_format_utils.h",
|
||||
"vk_google_filtering_precision.h",
|
||||
"vk_helpers.cpp",
|
||||
"vk_helpers.h",
|
||||
"vk_internal_shaders_autogen.cpp",
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "libANGLE/renderer/vulkan/VertexArrayVk.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_google_filtering_precision.h"
|
||||
#include "libANGLE/trace.h"
|
||||
#include "platform/Platform.h"
|
||||
|
||||
|
@ -1593,6 +1594,10 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev
|
|||
&mFeatures, supportsExternalMemoryFuchsia,
|
||||
ExtensionFound(VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME, deviceExtensionNames));
|
||||
|
||||
ANGLE_FEATURE_CONDITION(
|
||||
&mFeatures, supportsFilteringPrecision,
|
||||
ExtensionFound(VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME, deviceExtensionNames));
|
||||
|
||||
ANGLE_FEATURE_CONDITION(
|
||||
&mFeatures, supportsExternalFenceCapabilities,
|
||||
ExtensionFound(VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, deviceExtensionNames));
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "libANGLE/renderer/vulkan/RendererVk.h"
|
||||
#include "libANGLE/renderer/vulkan/VertexArrayVk.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_google_filtering_precision.h"
|
||||
#include "libANGLE/renderer/vulkan/vk_helpers.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
@ -1774,7 +1775,7 @@ void SamplerDesc::update(const gl::SamplerState &samplerState, bool stencilMode)
|
|||
mReserved = 0;
|
||||
}
|
||||
|
||||
VkSamplerCreateInfo SamplerDesc::unpack(ContextVk *contextVk) const
|
||||
angle::Result SamplerDesc::init(ContextVk *contextVk, vk::Sampler *sampler) const
|
||||
{
|
||||
const gl::Extensions &extensions = contextVk->getExtensions();
|
||||
|
||||
|
@ -1799,7 +1800,23 @@ VkSamplerCreateInfo SamplerDesc::unpack(ContextVk *contextVk) const
|
|||
createInfo.borderColor = VK_BORDER_COLOR_INT_TRANSPARENT_BLACK;
|
||||
createInfo.unnormalizedCoordinates = VK_FALSE;
|
||||
|
||||
return createInfo;
|
||||
// Note: because we don't detect changes to this hint (no dirty bit), if a sampler is created
|
||||
// with the hint enabled, and then the hint gets disabled, the next render will do so with the
|
||||
// hint enabled.
|
||||
VkSamplerFilteringPrecisionGOOGLE filteringInfo = {};
|
||||
GLenum hint = contextVk->getState().getTextureFilteringHint();
|
||||
if (hint == GL_NICEST)
|
||||
{
|
||||
ASSERT(extensions.textureFilteringCHROMIUM);
|
||||
filteringInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE;
|
||||
filteringInfo.samplerFilteringPrecisionMode =
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE;
|
||||
vk::AddToPNextChain(&createInfo, &filteringInfo);
|
||||
}
|
||||
|
||||
ANGLE_VK_TRY(contextVk, sampler->init(contextVk->getDevice(), createInfo));
|
||||
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
size_t SamplerDesc::hash() const
|
||||
|
@ -2158,10 +2175,8 @@ angle::Result SamplerCache::getSampler(ContextVk *contextVk,
|
|||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
VkSamplerCreateInfo createInfo = desc.unpack(contextVk);
|
||||
|
||||
vk::Sampler sampler;
|
||||
ANGLE_VK_TRY(contextVk, sampler.init(contextVk->getDevice(), createInfo));
|
||||
ANGLE_TRY(desc.init(contextVk, &sampler));
|
||||
|
||||
auto insertedItem = mPayload.emplace(desc, vk::RefCountedSampler(std::move(sampler)));
|
||||
vk::RefCountedSampler &insertedSampler = insertedItem.first->second;
|
||||
|
|
|
@ -609,7 +609,7 @@ class SamplerDesc final
|
|||
|
||||
void update(const gl::SamplerState &samplerState, bool stencilMode);
|
||||
void reset();
|
||||
VkSamplerCreateInfo unpack(ContextVk *contextVk) const;
|
||||
angle::Result init(ContextVk *contextVk, vk::Sampler *sampler) const;
|
||||
|
||||
size_t hash() const;
|
||||
bool operator==(const SamplerDesc &other) const;
|
||||
|
|
|
@ -186,6 +186,8 @@ void RendererVk::ensureCapsInitialized() const
|
|||
|
||||
mNativeExtensions.gpuShader5EXT = vk::CanSupportGPUShader5EXT(mPhysicalDeviceFeatures);
|
||||
|
||||
mNativeExtensions.textureFilteringCHROMIUM = getFeatures().supportsFilteringPrecision.enabled;
|
||||
|
||||
// https://vulkan.lunarg.com/doc/view/1.0.30.0/linux/vkspec.chunked/ch31s02.html
|
||||
mNativeCaps.maxElementIndex = std::numeric_limits<GLuint>::max() - 1;
|
||||
mNativeCaps.max3DTextureSize = LimitToInt(limitsVk.maxImageDimension3D);
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
|
||||
//
|
||||
// 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 "libANGLE/renderer/vulkan/vk_headers.h"
|
||||
|
||||
// THIS FILE SHOULD BE DELETED IF VK_GOOGLE_sampler_filtering_precision IS EVER ADDED TO THE VULKAN
|
||||
// HEADERS
|
||||
#ifdef VK_GOOGLE_sampler_filtering_precision
|
||||
# error \
|
||||
"VK_GOOGLE_sampler_filtering_precision is already defined in the Vulkan headers, you can delete this file"
|
||||
#endif
|
||||
|
||||
static constexpr VkStructureType VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE =
|
||||
static_cast<VkStructureType>(1000264000);
|
||||
|
||||
#define VK_GOOGLE_sampler_filtering_precisions 1
|
||||
#define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_SPEC_VERSION 1
|
||||
#define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME "VK_GOOGLE_sampler_filtering_precision"
|
||||
|
||||
const int TEXTURE_FILTERING_HINT_CHROMIUM = 0x8AF0;
|
||||
|
||||
typedef enum VkSamplerFilteringPrecisionModeGOOGLE
|
||||
{
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE = 0,
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE = 1,
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_BEGIN_RANGE_GOOGLE =
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE,
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_END_RANGE_GOOGLE =
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE,
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_RANGE_SIZE_GOOGLE =
|
||||
(VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE -
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE + 1),
|
||||
VK_SAMPLER_FILTERING_PRECISION_MODE_MAX_ENUM_GOOGLE = 0x7FFFFFFF
|
||||
} VkSamplerFilteringPrecisionModeGOOGLE;
|
||||
|
||||
typedef struct VkSamplerFilteringPrecisionGOOGLE
|
||||
{
|
||||
VkStructureType sType;
|
||||
const void *pNext;
|
||||
VkSamplerFilteringPrecisionModeGOOGLE samplerFilteringPrecisionMode;
|
||||
} VkSamplerFilteringPrecisionGOOGLE;
|
|
@ -5059,6 +5059,14 @@ bool ValidateHint(const Context *context, GLenum target, GLenum mode)
|
|||
case GL_GENERATE_MIPMAP_HINT:
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
|
||||
if (!context->getExtensions().textureFilteringCHROMIUM)
|
||||
{
|
||||
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT:
|
||||
if (context->getClientVersion() < ES_3_0 &&
|
||||
!context->getExtensions().standardDerivativesOES)
|
||||
|
|
|
@ -119,6 +119,7 @@ angle_end2end_tests_sources = [
|
|||
"gl_tests/SwizzleTest.cpp",
|
||||
"gl_tests/SyncQueriesTest.cpp",
|
||||
"gl_tests/TextureExternalUpdateTest.cpp",
|
||||
"gl_tests/TextureFilteringHintTest.cpp",
|
||||
"gl_tests/TextureMultisampleTest.cpp",
|
||||
"gl_tests/TextureRectangleTest.cpp",
|
||||
"gl_tests/TextureTest.cpp",
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// TextureFilteringHintTest.cpp : Tests of the GL_CHROMIUM_texture_filtering_hint extension.
|
||||
|
||||
#include "test_utils/ANGLETest.h"
|
||||
|
||||
#include "test_utils/gl_raii.h"
|
||||
|
||||
namespace angle
|
||||
{
|
||||
|
||||
class TextureFilteringHintTest : public ANGLETest
|
||||
{
|
||||
protected:
|
||||
TextureFilteringHintTest()
|
||||
{
|
||||
setWindowWidth(128);
|
||||
setWindowHeight(128);
|
||||
setConfigRedBits(8);
|
||||
setConfigGreenBits(8);
|
||||
setConfigBlueBits(8);
|
||||
setConfigAlphaBits(8);
|
||||
}
|
||||
};
|
||||
|
||||
// Test that setting the hint works only when the extension is enabled
|
||||
TEST_P(TextureFilteringHintTest, Validation)
|
||||
{
|
||||
if (IsGLExtensionEnabled("GL_CHROMIUM_texture_filtering_hint"))
|
||||
{
|
||||
GLint intValue = 0;
|
||||
glGetIntegerv(GL_TEXTURE_FILTERING_HINT_CHROMIUM, &intValue);
|
||||
EXPECT_GL_NO_ERROR();
|
||||
EXPECT_GLENUM_EQ(GL_DONT_CARE, intValue);
|
||||
|
||||
glHint(GL_TEXTURE_FILTERING_HINT_CHROMIUM, GL_FASTEST);
|
||||
glGetIntegerv(GL_TEXTURE_FILTERING_HINT_CHROMIUM, &intValue);
|
||||
EXPECT_GL_NO_ERROR();
|
||||
EXPECT_GLENUM_EQ(GL_FASTEST, intValue);
|
||||
|
||||
glHint(GL_TEXTURE_FILTERING_HINT_CHROMIUM, GL_NICEST);
|
||||
glGetIntegerv(GL_TEXTURE_FILTERING_HINT_CHROMIUM, &intValue);
|
||||
EXPECT_GL_NO_ERROR();
|
||||
EXPECT_GLENUM_EQ(GL_NICEST, intValue);
|
||||
|
||||
glHint(GL_TEXTURE_FILTERING_HINT_CHROMIUM, GL_TEXTURE_2D);
|
||||
glGetIntegerv(GL_TEXTURE_FILTERING_HINT_CHROMIUM, &intValue);
|
||||
EXPECT_GL_ERROR(GL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
{
|
||||
glHint(GL_TEXTURE_FILTERING_HINT_CHROMIUM, GL_FASTEST);
|
||||
EXPECT_GL_ERROR(GL_INVALID_ENUM);
|
||||
}
|
||||
}
|
||||
|
||||
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
|
||||
// tests should be run against.
|
||||
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(TextureFilteringHintTest);
|
||||
} // namespace angle
|
Загрузка…
Ссылка в новой задаче