diff --git a/scripts/run_code_generation_hashes.json b/scripts/run_code_generation_hashes.json index 610e50fc5..3a08bd15e 100644 --- a/scripts/run_code_generation_hashes.json +++ b/scripts/run_code_generation_hashes.json @@ -94,5 +94,5 @@ "proc table:src/libGLESv2/proc_table_data.json": "2c452ae503df669222e85961ab75fb22", "uniform type:src/common/gen_uniform_type_table.py": - "261d239af143eeb4bd3d69cdd53ee096" + "59cb4ffd0f584c4bd37f2f4ff59a2b93" } \ No newline at end of file diff --git a/src/common/PackedEnums.cpp b/src/common/PackedEnums.cpp index 6ba79d52c..805c3b821 100644 --- a/src/common/PackedEnums.cpp +++ b/src/common/PackedEnums.cpp @@ -142,6 +142,11 @@ TextureType SamplerTypeToTextureType(GLenum samplerType) case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: return TextureType::_2DMultisample; + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + return TextureType::_2DMultisampleArray; + case GL_SAMPLER_2D_RECT_ANGLE: return TextureType::Rectangle; @@ -151,6 +156,18 @@ TextureType SamplerTypeToTextureType(GLenum samplerType) } } +bool IsMultisampled(gl::TextureType type) +{ + switch (type) + { + case gl::TextureType::_2DMultisample: + case gl::TextureType::_2DMultisampleArray: + return true; + default: + return false; + } +} + } // namespace gl namespace egl diff --git a/src/common/PackedEnums.h b/src/common/PackedEnums.h index 3c567268b..d76092da3 100644 --- a/src/common/PackedEnums.h +++ b/src/common/PackedEnums.h @@ -187,6 +187,8 @@ using ShaderMap = angle::PackedEnumMap; TextureType SamplerTypeToTextureType(GLenum samplerType); +bool IsMultisampled(gl::TextureType type); + } // namespace gl namespace egl diff --git a/src/common/gen_uniform_type_table.py b/src/common/gen_uniform_type_table.py index c824eef10..e1eaedb19 100644 --- a/src/common/gen_uniform_type_table.py +++ b/src/common/gen_uniform_type_table.py @@ -41,6 +41,7 @@ all_uniform_types = [ "GL_INT_SAMPLER_2D", "GL_INT_SAMPLER_2D_ARRAY", "GL_INT_SAMPLER_2D_MULTISAMPLE", + "GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_INT_SAMPLER_3D", "GL_INT_SAMPLER_CUBE", "GL_INT_VEC2", @@ -50,6 +51,7 @@ all_uniform_types = [ "GL_SAMPLER_2D_ARRAY", "GL_SAMPLER_2D_ARRAY_SHADOW", "GL_SAMPLER_2D_MULTISAMPLE", + "GL_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_SAMPLER_2D_RECT_ANGLE", "GL_SAMPLER_2D_SHADOW", "GL_SAMPLER_3D", @@ -65,6 +67,7 @@ all_uniform_types = [ "GL_UNSIGNED_INT_SAMPLER_2D", "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY", "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE", + "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_UNSIGNED_INT_SAMPLER_3D", "GL_UNSIGNED_INT_SAMPLER_CUBE", "GL_UNSIGNED_INT_VEC2", @@ -79,6 +82,7 @@ texture_types = { "2D_ARRAY": "2D_ARRAY", "2D_ARRAY_SHADOW": "2D_ARRAY", "2D_MULTISAMPLE": "2D_MULTISAMPLE", + "2D_MULTISAMPLE_ARRAY": "2D_MULTISAMPLE_ARRAY", "2D_RECT_ANGLE": "2D", "2D_SHADOW": "2D", "3D": "3D", diff --git a/src/common/uniform_type_info_autogen.cpp b/src/common/uniform_type_info_autogen.cpp index fc179757f..b0c44ee65 100644 --- a/src/common/uniform_type_info_autogen.cpp +++ b/src/common/uniform_type_info_autogen.cpp @@ -18,7 +18,7 @@ namespace gl namespace { -constexpr std::array kInfoTable = { +constexpr std::array kInfoTable = { {{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0 * 0, 0 * 0, false, false, false}, {GL_BOOL, GL_BOOL, GL_NONE, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, false}, @@ -78,6 +78,8 @@ constexpr std::array kInfoTable = { sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, {GL_INT_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D_MULTISAMPLE, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, + {GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_INT, GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_NONE, + GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, {GL_INT_SAMPLER_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, {GL_INT_SAMPLER_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), @@ -96,6 +98,8 @@ constexpr std::array kInfoTable = { sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, {GL_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D_MULTISAMPLE, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, + {GL_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_INT, GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_NONE, GL_NONE, 1, + 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, {GL_SAMPLER_2D_RECT_ANGLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, {GL_SAMPLER_2D_SHADOW, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), @@ -126,6 +130,9 @@ constexpr std::array kInfoTable = { 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, {GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GL_UNSIGNED_INT, GL_TEXTURE_2D_MULTISAMPLE, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, + {GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_UNSIGNED_INT, + GL_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLuint), + sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, {GL_UNSIGNED_INT_SAMPLER_3D, GL_UNSIGNED_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, {GL_UNSIGNED_INT_SAMPLER_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, @@ -201,64 +208,70 @@ size_t GetTypeInfoIndex(GLenum uniformType) return 28; case GL_INT_SAMPLER_2D_MULTISAMPLE: return 29; - case GL_INT_SAMPLER_3D: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: return 30; - case GL_INT_SAMPLER_CUBE: + case GL_INT_SAMPLER_3D: return 31; - case GL_INT_VEC2: + case GL_INT_SAMPLER_CUBE: return 32; - case GL_INT_VEC3: + case GL_INT_VEC2: return 33; - case GL_INT_VEC4: + case GL_INT_VEC3: return 34; - case GL_SAMPLER_2D: + case GL_INT_VEC4: return 35; - case GL_SAMPLER_2D_ARRAY: + case GL_SAMPLER_2D: return 36; - case GL_SAMPLER_2D_ARRAY_SHADOW: + case GL_SAMPLER_2D_ARRAY: return 37; - case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D_ARRAY_SHADOW: return 38; - case GL_SAMPLER_2D_RECT_ANGLE: + case GL_SAMPLER_2D_MULTISAMPLE: return 39; - case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: return 40; - case GL_SAMPLER_3D: + case GL_SAMPLER_2D_RECT_ANGLE: return 41; - case GL_SAMPLER_CUBE: + case GL_SAMPLER_2D_SHADOW: return 42; - case GL_SAMPLER_CUBE_SHADOW: + case GL_SAMPLER_3D: return 43; - case GL_SAMPLER_EXTERNAL_OES: + case GL_SAMPLER_CUBE: return 44; - case GL_UNSIGNED_INT: + case GL_SAMPLER_CUBE_SHADOW: return 45; - case GL_UNSIGNED_INT_ATOMIC_COUNTER: + case GL_SAMPLER_EXTERNAL_OES: return 46; - case GL_UNSIGNED_INT_IMAGE_2D: + case GL_UNSIGNED_INT: return 47; - case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: + case GL_UNSIGNED_INT_ATOMIC_COUNTER: return 48; - case GL_UNSIGNED_INT_IMAGE_3D: + case GL_UNSIGNED_INT_IMAGE_2D: return 49; - case GL_UNSIGNED_INT_IMAGE_CUBE: + case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: return 50; - case GL_UNSIGNED_INT_SAMPLER_2D: + case GL_UNSIGNED_INT_IMAGE_3D: return 51; - case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE: return 52; - case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D: return 53; - case GL_UNSIGNED_INT_SAMPLER_3D: + case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: return 54; - case GL_UNSIGNED_INT_SAMPLER_CUBE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: return 55; - case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: return 56; - case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_SAMPLER_3D: return 57; - case GL_UNSIGNED_INT_VEC4: + case GL_UNSIGNED_INT_SAMPLER_CUBE: return 58; + case GL_UNSIGNED_INT_VEC2: + return 59; + case GL_UNSIGNED_INT_VEC3: + return 60; + case GL_UNSIGNED_INT_VEC4: + return 61; default: UNREACHABLE(); return 0; diff --git a/src/common/utilities.cpp b/src/common/utilities.cpp index 19818491a..bef61ae3f 100644 --- a/src/common/utilities.cpp +++ b/src/common/utilities.cpp @@ -131,16 +131,19 @@ GLenum VariableComponentType(GLenum type) case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: @@ -259,16 +262,19 @@ int VariableRowCount(GLenum type) case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_RECT_ANGLE: case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: @@ -320,11 +326,13 @@ int VariableColumnCount(GLenum type) case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_RECT_ANGLE: case GL_UNSIGNED_INT_SAMPLER_2D: @@ -332,6 +340,7 @@ int VariableColumnCount(GLenum type) case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: @@ -390,17 +399,20 @@ bool IsSamplerType(GLenum type) case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_2D_RECT_ANGLE: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: @@ -652,17 +664,20 @@ int VariableSortOrder(GLenum type) case GL_SAMPLER_2D_RECT_ANGLE: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_3D: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: case GL_SAMPLER_CUBE_SHADOW: diff --git a/src/compiler/translator/util.cpp b/src/compiler/translator/util.cpp index 067b7de5d..c01df81dc 100644 --- a/src/compiler/translator/util.cpp +++ b/src/compiler/translator/util.cpp @@ -375,6 +375,8 @@ GLenum GLVariableType(const TType &type) return GL_SAMPLER_2D_ARRAY; case EbtSampler2DMS: return GL_SAMPLER_2D_MULTISAMPLE; + case EbtSampler2DMSArray: + return GL_SAMPLER_2D_MULTISAMPLE_ARRAY; case EbtISampler2D: return GL_INT_SAMPLER_2D; case EbtISampler3D: @@ -385,6 +387,8 @@ GLenum GLVariableType(const TType &type) return GL_INT_SAMPLER_2D_ARRAY; case EbtISampler2DMS: return GL_INT_SAMPLER_2D_MULTISAMPLE; + case EbtISampler2DMSArray: + return GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY; case EbtUSampler2D: return GL_UNSIGNED_INT_SAMPLER_2D; case EbtUSampler3D: @@ -395,6 +399,8 @@ GLenum GLVariableType(const TType &type) return GL_UNSIGNED_INT_SAMPLER_2D_ARRAY; case EbtUSampler2DMS: return GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE; + case EbtUSampler2DMSArray: + return GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY; case EbtSampler2DShadow: return GL_SAMPLER_2D_SHADOW; case EbtSamplerCubeShadow: diff --git a/src/libANGLE/Compiler.cpp b/src/libANGLE/Compiler.cpp index bd227343a..954065130 100644 --- a/src/libANGLE/Compiler.cpp +++ b/src/libANGLE/Compiler.cpp @@ -79,6 +79,8 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state) mResources.OES_EGL_image_external_essl3 = extensions.eglImageExternalEssl3; mResources.NV_EGL_stream_consumer_external = extensions.eglStreamConsumerExternal; mResources.ARB_texture_rectangle = extensions.textureRectangle; + mResources.OES_texture_storage_multisample_2d_array = + extensions.textureStorageMultisample2DArray; // TODO: use shader precision caps to determine if high precision is supported? mResources.FragmentPrecisionHigh = 1; mResources.EXT_frag_depth = extensions.fragDepth; diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp index f402be195..5fa02bcb5 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp @@ -7475,6 +7475,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu case GL_SHADER_STORAGE_BUFFER_BINDING: case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT: case GL_TEXTURE_BINDING_2D_MULTISAMPLE: + case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: *type = GL_INT; *numParams = 1; return true; diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp index 7248623d2..f52459ba1 100644 --- a/src/libANGLE/State.cpp +++ b/src/libANGLE/State.cpp @@ -2407,6 +2407,11 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params) *params = getSamplerTextureId(static_cast(mActiveSampler), TextureType::_2DMultisample); break; + case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: + ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); + *params = getSamplerTextureId(static_cast(mActiveSampler), + TextureType::_2DMultisampleArray); + break; case GL_TEXTURE_BINDING_EXTERNAL_OES: ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits); *params = getSamplerTextureId(static_cast(mActiveSampler), diff --git a/src/libANGLE/Texture.cpp b/src/libANGLE/Texture.cpp index af179d243..4fede59a2 100644 --- a/src/libANGLE/Texture.cpp +++ b/src/libANGLE/Texture.cpp @@ -271,7 +271,7 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState, // is NEAREST_MIPMAP_LINEAR and magFilter is LINEAR(table 20.11,). For multismaple texture, // filter state of multisample texture is ignored(11.1.3.3). So it shouldn't be judged as // incomplete texture. So, we ignore filtering for multisample texture completeness here. - if (mType != TextureType::_2DMultisample && + if (!IsMultisampled(mType) && !baseImageDesc.format.info->filterSupport(data.getClientVersion(), data.getExtensions()) && !IsPointSampled(samplerState)) { @@ -336,7 +336,7 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState, // depth and stencil format (see table 3.13), the value of TEXTURE_COMPARE_- // MODE is NONE, and either the magnification filter is not NEAREST or the mini- // fication filter is neither NEAREST nor NEAREST_MIPMAP_NEAREST. - if (mType != TextureType::_2DMultisample && baseImageDesc.format.info->depthBits > 0 && + if (!IsMultisampled(mType) && baseImageDesc.format.info->depthBits > 0 && data.getClientMajorVersion() >= 3) { // Note: we restrict this validation to sized types. For the OES_depth_textures @@ -363,7 +363,7 @@ bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState, // For multismaple texture, filter state of multisample texture is ignored(11.1.3.3). // So it shouldn't be judged as incomplete texture. So, we ignore filtering for multisample // texture completeness here. - if (mType != TextureType::_2DMultisample && baseImageDesc.format.info->depthBits > 0 && + if (!IsMultisampled(mType) && baseImageDesc.format.info->depthBits > 0 && mDepthStencilTextureMode == GL_STENCIL_INDEX) { if ((samplerState.minFilter != GL_NEAREST && diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp index 2ea861e37..b9edd5b9e 100644 --- a/src/libANGLE/renderer/gl/FramebufferGL.cpp +++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp @@ -61,7 +61,8 @@ void BindFramebufferAttachment(const FunctionsGL *functions, { TextureType textureType = texture->getType(); ASSERT(textureType == TextureType::_2DArray || textureType == TextureType::_3D || - textureType == TextureType::CubeMap); + textureType == TextureType::CubeMap || + textureType == TextureType::_2DMultisampleArray); functions->framebufferTexture(GL_FRAMEBUFFER, attachmentPoint, textureGL->getTextureID(), attachment->mipLevel()); } diff --git a/src/tests/deqp_support/deqp_gles31_test_expectations.txt b/src/tests/deqp_support/deqp_gles31_test_expectations.txt index db39d1ee0..6536beda7 100644 --- a/src/tests/deqp_support/deqp_gles31_test_expectations.txt +++ b/src/tests/deqp_support/deqp_gles31_test_expectations.txt @@ -1598,65 +1598,6 @@ // An NVIDIA bug seems to occur when sending GL commands in a certain order to the driver 2432 NVIDIA OPENGL : dEQP-GLES31.functional.vertex_attribute_binding.usage.mixed_usage.mixed_api_change_binding_point = SKIP -// OES_texture_storage_multisample_2d_array is exposed on OpenGL but not yet fully implemented. -2775 OPENGL : dEQP-GLES31.functional.state_query.integer.texture_binding_2d_multisample_array* = FAIL -2775 OPENGL : dEQP-GLES31.functional.state_query.shader.sampler_type_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_2.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_2.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_2.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_2.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_3.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_3.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_3.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_3.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_4.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_4.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_4.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_4.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_8.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_8.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_8.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_8.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_10.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_10.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_10.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_10.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_12.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_12.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_12.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_12.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_13.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_13.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_13.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_13.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_64.use_texture_color_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_64.use_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_64.use_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_64.use_texture_depth_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_1_texture_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_4_texture_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_1_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_4_texture_int_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_1_texture_uint_2d_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_4_texture_uint_2d_array = FAIL - -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.layered.render_with_default_layer_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.layered.render_to_one_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.layered.render_to_all_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.layered.render_different_to_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.layered.fragment_layer_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.layered.layer_provoking_vertex_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.instanced.invocation_per_layer_2d_multisample_array = FAIL -2775 OPENGL : dEQP-GLES31.functional.geometry_shading.instanced.multiple_layers_per_invocation_2d_multisample_array = FAIL - // OpenGL and D3D11 Failing Tests 1442 OPENGL D3D11 : dEQP-GLES31.functional.shaders.opaque_type_indexing.* = FAIL 1442 OPENGL D3D11 : dEQP-GLES31.functional.shaders.helper_invocation.* = FAIL diff --git a/src/tests/gl_tests/TextureMultisampleTest.cpp b/src/tests/gl_tests/TextureMultisampleTest.cpp index 9c91611ad..9866ea3b9 100644 --- a/src/tests/gl_tests/TextureMultisampleTest.cpp +++ b/src/tests/gl_tests/TextureMultisampleTest.cpp @@ -7,6 +7,8 @@ // TextureMultisampleTest: Tests of multisampled texture #include "test_utils/ANGLETest.h" + +#include "shader_utils.h" #include "test_utils/gl_raii.h" using namespace angle; @@ -77,6 +79,50 @@ class TextureMultisampleTest : public ANGLETest } return maxSamples; } + + const char *blitArrayTextureLayerFragmentShader() + { + return R"(#version 310 es +#extension GL_OES_texture_storage_multisample_2d_array : require +precision highp float; +precision highp int; + +uniform highp sampler2DMSArray tex; +uniform int layer; +uniform int sampleNum; + +in vec4 v_position; +out vec4 my_FragColor; + +void main() { + ivec3 texSize = textureSize(tex); + ivec2 sampleCoords = ivec2((v_position.xy * 0.5 + 0.5) * vec2(texSize.xy - 1)); + my_FragColor = texelFetch(tex, ivec3(sampleCoords, layer), sampleNum); +} +)"; + }; + + const char *blitIntArrayTextureLayerFragmentShader() + { + return R"(#version 310 es +#extension GL_OES_texture_storage_multisample_2d_array : require +precision highp float; +precision highp int; + +uniform highp isampler2DMSArray tex; +uniform int layer; +uniform int sampleNum; + +in vec4 v_position; +out vec4 my_FragColor; + +void main() { + ivec3 texSize = textureSize(tex); + ivec2 sampleCoords = ivec2((v_position.xy * 0.5 + 0.5) * vec2(texSize.xy - 1)); + my_FragColor = vec4(texelFetch(tex, ivec3(sampleCoords, layer), sampleNum)); +} +)"; + }; }; class TextureMultisampleTestES31 : public TextureMultisampleTest @@ -286,6 +332,37 @@ TEST_P(TextureMultisampleArrayWebGLTest, BindMultisampleArrayTextureWithoutExten ASSERT_GL_ERROR(GL_INVALID_ENUM); } +// Try to compile shaders using GL_OES_texture_storage_multisample_2d_array when the extension is +// not enabled. +TEST_P(TextureMultisampleArrayWebGLTest, ShaderWithoutExtension) +{ + const std::string &fragmentShaderRequireExtension = R"(#version 310 es + #extension GL_OES_texture_storage_multisample_2d_array : require + out highp vec4 my_FragColor; + + void main() { + my_FragColor = vec4(0.0); + } + )"; + + GLuint program = CompileProgram(essl31_shaders::vs::Simple(), fragmentShaderRequireExtension); + EXPECT_EQ(0u, program); + + const std::string &fragmentShaderEnableAndUseExtension = R"(#version 310 es + #extension GL_OES_texture_storage_multisample_2d_array : enable + + uniform highp sampler2DMSArray tex; + out highp ivec4 outSize; + + void main() { + outSize = ivec4(textureSize(tex), 0); + } + )"; + + program = CompileProgram(essl31_shaders::vs::Simple(), fragmentShaderEnableAndUseExtension); + EXPECT_EQ(0u, program); +} + // Tests that GL_TEXTURE_2D_MULTISAMPLE_ARRAY is supported in GetInternalformativ. TEST_P(TextureMultisampleArrayWebGLTest, MultisampleArrayTargetGetInternalFormativ) { @@ -558,6 +635,166 @@ TEST_P(TextureMultisampleArrayWebGLTest, FramebufferColorClearAndBlit) EXPECT_PIXEL_RECT_EQ(0, 0, kWidth, kHeight, GLColor::green); } +// Check the size of a multisample array texture in a shader. +TEST_P(TextureMultisampleArrayWebGLTest, TextureSizeInShader) +{ + ANGLE_SKIP_TEST_IF(!requestArrayExtension()); + + const std::string &fragmentShader = R"(#version 310 es + #extension GL_OES_texture_storage_multisample_2d_array : require + + uniform highp sampler2DMSArray tex; + out highp vec4 my_FragColor; + + void main() { + my_FragColor = (textureSize(tex) == ivec3(8, 4, 2)) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1); + } + )"; + + ANGLE_GL_PROGRAM(texSizeProgram, essl31_shaders::vs::Simple(), fragmentShader); + + GLint texLocation = glGetUniformLocation(texSizeProgram, "tex"); + ASSERT_GE(texLocation, 0); + + const GLsizei kWidth = 8; + const GLsizei kHeight = 4; + + std::vector testFormats = {GL_RGBA8}; + GLint samplesToUse = getSamplesToUse(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, testFormats); + + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, mTexture); + glTexStorage3DMultisampleOES(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, samplesToUse, GL_RGBA8, + kWidth, kHeight, 2, GL_TRUE); + ASSERT_GL_NO_ERROR(); + + drawQuad(texSizeProgram, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true); + ASSERT_GL_NO_ERROR(); + + EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); +} + +// Clear the layers of a multisample array texture, and then sample all the samples from all the +// layers in a shader. +TEST_P(TextureMultisampleArrayWebGLTest, SimpleTexelFetch) +{ + ANGLE_SKIP_TEST_IF(!requestArrayExtension()); + + ANGLE_GL_PROGRAM(texelFetchProgram, essl31_shaders::vs::Passthrough(), + blitArrayTextureLayerFragmentShader()); + + GLint texLocation = glGetUniformLocation(texelFetchProgram, "tex"); + ASSERT_GE(texLocation, 0); + GLint layerLocation = glGetUniformLocation(texelFetchProgram, "layer"); + ASSERT_GE(layerLocation, 0); + GLint sampleNumLocation = glGetUniformLocation(texelFetchProgram, "sampleNum"); + ASSERT_GE(layerLocation, 0); + + const GLsizei kWidth = 4; + const GLsizei kHeight = 4; + const GLsizei kLayerCount = 2; + + std::vector testFormats = {GL_RGBA8}; + GLint samplesToUse = getSamplesToUse(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, testFormats); + + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, mTexture); + glTexStorage3DMultisampleOES(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, samplesToUse, GL_RGBA8, + kWidth, kHeight, kLayerCount, GL_TRUE); + ASSERT_GL_NO_ERROR(); + + // Clear layer zero to green and layer one to blue. + glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); + std::vector clearColors = {{GLColor::green, GLColor::blue}}; + for (GLint i = 0; static_cast(i) < kLayerCount; ++i) + { + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTexture, 0, i); + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, status); + const GLColor &clearColor = clearColors[i]; + glClearColor(clearColor.R / 255.0f, clearColor.G / 255.0f, clearColor.B / 255.0f, + clearColor.A / 255.0f); + glClear(GL_COLOR_BUFFER_BIT); + ASSERT_GL_NO_ERROR(); + } + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glUseProgram(texelFetchProgram); + glViewport(0, 0, kWidth, kHeight); + for (GLint layer = 0; static_cast(layer) < kLayerCount; ++layer) + { + glUniform1i(layerLocation, layer); + for (GLint sampleNum = 0; sampleNum < samplesToUse; ++sampleNum) + { + glUniform1i(sampleNumLocation, sampleNum); + drawQuad(texelFetchProgram, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true); + ASSERT_GL_NO_ERROR(); + EXPECT_PIXEL_RECT_EQ(0, 0, kWidth, kHeight, clearColors[layer]); + } + } +} + +// Clear the layers of an integer multisample array texture, and then sample all the samples from +// all the layers in a shader. +TEST_P(TextureMultisampleArrayWebGLTest, IntegerTexelFetch) +{ + ANGLE_SKIP_TEST_IF(!requestArrayExtension()); + + ANGLE_GL_PROGRAM(texelFetchProgram, essl31_shaders::vs::Passthrough(), + blitIntArrayTextureLayerFragmentShader()); + + GLint texLocation = glGetUniformLocation(texelFetchProgram, "tex"); + ASSERT_GE(texLocation, 0); + GLint layerLocation = glGetUniformLocation(texelFetchProgram, "layer"); + ASSERT_GE(layerLocation, 0); + GLint sampleNumLocation = glGetUniformLocation(texelFetchProgram, "sampleNum"); + ASSERT_GE(layerLocation, 0); + + const GLsizei kWidth = 4; + const GLsizei kHeight = 4; + const GLsizei kLayerCount = 2; + + std::vector testFormats = {GL_RGBA8I}; + GLint samplesToUse = getSamplesToUse(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, testFormats); + + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, mTexture); + glTexStorage3DMultisampleOES(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, samplesToUse, GL_RGBA8I, + kWidth, kHeight, kLayerCount, GL_TRUE); + ASSERT_GL_NO_ERROR(); + + // Clear layer zero to green and layer one to blue. + glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); + std::vector clearColors = {{GLColor::green, GLColor::blue}}; + for (GLint i = 0; static_cast(i) < kLayerCount; ++i) + { + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTexture, 0, i); + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, status); + std::array intColor; + for (size_t j = 0; j < intColor.size(); ++j) + { + intColor[j] = clearColors[i][j] / 255; + } + glClearBufferiv(GL_COLOR, 0, intColor.data()); + ASSERT_GL_NO_ERROR(); + } + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glUseProgram(texelFetchProgram); + glViewport(0, 0, kWidth, kHeight); + for (GLint layer = 0; static_cast(layer) < kLayerCount; ++layer) + { + glUniform1i(layerLocation, layer); + for (GLint sampleNum = 0; sampleNum < samplesToUse; ++sampleNum) + { + glClearColor(1.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + glUniform1i(sampleNumLocation, sampleNum); + drawQuad(texelFetchProgram, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true); + ASSERT_GL_NO_ERROR(); + EXPECT_PIXEL_RECT_EQ(0, 0, kWidth, kHeight, clearColors[layer]); + } + } +} + ANGLE_INSTANTIATE_TEST(TextureMultisampleTest, ES31_D3D11(), ES3_OPENGL(), diff --git a/util/shader_utils.cpp b/util/shader_utils.cpp index e4cdaa53a..40d469b57 100644 --- a/util/shader_utils.cpp +++ b/util/shader_utils.cpp @@ -310,7 +310,7 @@ void main() } // A shader that simply passes through attribute a_position, setting it to gl_Position and varying -// pos. +// v_position. const char *Passthrough() { return R"(precision highp float; @@ -468,6 +468,20 @@ void main() })"; } +// A shader that simply passes through attribute a_position, setting it to gl_Position and varying +// v_position. +const char *Passthrough() +{ + return R"(#version 310 es +in vec4 a_position; +out vec4 v_position; +void main() +{ + gl_Position = a_position; + v_position = a_position; +})"; +} + } // namespace vs namespace fs diff --git a/util/shader_utils.h b/util/shader_utils.h index 176f55f00..152004760 100644 --- a/util/shader_utils.h +++ b/util/shader_utils.h @@ -130,6 +130,10 @@ ANGLE_EXPORT const char *Zero(); // A shader that sets gl_Position to attribute a_position. ANGLE_EXPORT const char *Simple(); +// A shader that simply passes through attribute a_position, setting it to gl_Position and varying +// v_position. +ANGLE_EXPORT const char *Passthrough(); + } // namespace vs namespace fs