Hash :
0ea24ef2
Author :
Date :
2024-01-26T16:50:39
Unsuppress passing tests Bug: angleproject:3871 Bug: angleproject:3872 Bug: angleproject:3879 Bug: angleproject:4686 Bug: angleproject:4704 Bug: angleproject:4718 Bug: angleproject:4721 Bug: angleproject:4792 Bug: angleproject:5086 Bug: angleproject:5313 Bug: angleproject:6109 Change-Id: I0d0f88a388cd2f19da99a7defd0ab8d98db0e6e0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5241306 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
//
// 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.
//
// VulkanFramebufferTest:
// Tests to validate our Vulkan framebuffer image allocation.
//
#include "test_utils/ANGLETest.h"
#include "test_utils/angle_test_instantiate.h"
// 'None' is defined as 'struct None {};' in
// third_party/googletest/src/googletest/include/gtest/internal/gtest-type-util.h.
// But 'None' is also defined as a numeric constant 0L in <X11/X.h>.
// So we need to include ANGLETest.h first to avoid this conflict.
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/TextureVk.h"
#include "test_utils/gl_raii.h"
#include "util/EGLWindow.h"
#include "util/shader_utils.h"
using namespace angle;
namespace
{
class VulkanFramebufferTest : public ANGLETest<>
{
protected:
gl::Context *hackContext() const
{
egl::Display *display = static_cast<egl::Display *>(getEGLWindow()->getDisplay());
gl::ContextID contextID = {
static_cast<GLuint>(reinterpret_cast<uintptr_t>(getEGLWindow()->getContext()))};
return display->getContext(contextID);
}
rx::ContextVk *hackANGLE() const
{
// Hack the angle!
return rx::GetImplAs<rx::ContextVk>(hackContext());
}
rx::TextureVk *hackTexture(GLuint handle) const
{
// Hack the angle!
const gl::Context *context = hackContext();
const gl::Texture *texture = context->getTexture({handle});
return rx::vk::GetImpl(texture);
}
};
// Test that framebuffer can be created from a mip-incomplete texture, and that its allocation only
// includes the framebuffer's attached mip.
TEST_P(VulkanFramebufferTest, TextureAttachmentMipIncomplete)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 100, 100, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, 5, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
// Set framebuffer to mip 0. Framebuffer should be complete, and make the texture allocate
// an image of only 1 level.
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
glClearColor(0, 0, 0, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
rx::TextureVk *textureVk = hackTexture(texture);
EXPECT_EQ(textureVk->getImage().getLevelCount(), 1u);
}
// Test ensure that a R4G4B4A4 format sample only will actually uses R4G4B4A4 format instead of
// R8G8B8A8.
TEST_P(VulkanFramebufferTest, R4G4B4A4TextureSampleOnlyActuallyUses444Format)
{
rx::ContextVk *contextVk = hackANGLE();
rx::RendererVk *renderer = contextVk->getRenderer();
angle::FormatID formatID = angle::FormatID::R4G4B4A4_UNORM;
// Check if R4G4B4A4_UNORM is supported format.
bool isTexturable = renderer->hasImageFormatFeatureBits(
formatID,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
ANGLE_SKIP_TEST_IF(!isTexturable);
static constexpr GLsizei kTexWidth = 100;
static constexpr GLsizei kTexHeight = 100;
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
const GLushort u16Color = 0xF00F; // red
std::vector<GLushort> pixels(kTexWidth * kTexHeight, u16Color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA4, kTexWidth, kTexHeight, 0, GL_RGBA,
GL_UNSIGNED_SHORT_4_4_4_4, pixels.data());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Texture2DLod(), essl3_shaders::fs::Texture2DLod());
glUseProgram(program);
GLint textureLocation = glGetUniformLocation(program, essl3_shaders::Texture2DUniform());
ASSERT_NE(-1, textureLocation);
GLint lodLocation = glGetUniformLocation(program, essl3_shaders::LodUniform());
ASSERT_NE(-1, lodLocation);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glClearColor(0, 1, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glUniform1f(lodLocation, 0);
drawQuad(program, essl3_shaders::PositionAttrib(), 0.5f);
EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 255, 0, 0, 255);
ASSERT_GL_NO_ERROR();
rx::TextureVk *textureVk = hackTexture(texture);
EXPECT_EQ(textureVk->getImage().getActualFormatID(), formatID);
}
ANGLE_INSTANTIATE_TEST(VulkanFramebufferTest, ES3_VULKAN());
} // anonymous namespace