Commit e8789a53 by Tim Van Patten Committed by Commit Bot

Vulkan: Don't always end the render pass when updating the scissor

We don't always need to end the render pass when updating the scissor, since it will be ended later when necessary. This change is in preparation for optimizing resolving multisample images with glBlit, since the render pass needs to be updated before it's ended. Bug: angleproject:4753 Test: CQ Change-Id: Ie657587ca9f4461dcc03f0f9c251ac2c17398f5b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2327334Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 277ad4e0
...@@ -2678,7 +2678,7 @@ void ContextVk::updateDepthRange(float nearPlane, float farPlane) ...@@ -2678,7 +2678,7 @@ void ContextVk::updateDepthRange(float nearPlane, float farPlane)
mGraphicsPipelineDesc->updateDepthRange(&mGraphicsPipelineTransition, nearPlane, farPlane); mGraphicsPipelineDesc->updateDepthRange(&mGraphicsPipelineTransition, nearPlane, farPlane);
} }
angle::Result ContextVk::updateScissor(const gl::State &glState) angle::Result ContextVk::updateScissorImpl(const gl::State &glState, bool shouldEndRenderPass)
{ {
FramebufferVk *framebufferVk = vk::GetImpl(glState.getDrawFramebuffer()); FramebufferVk *framebufferVk = vk::GetImpl(glState.getDrawFramebuffer());
gl::Rectangle renderArea = framebufferVk->getNonRotatedCompleteRenderArea(); gl::Rectangle renderArea = framebufferVk->getNonRotatedCompleteRenderArea();
...@@ -2707,7 +2707,7 @@ angle::Result ContextVk::updateScissor(const gl::State &glState) ...@@ -2707,7 +2707,7 @@ angle::Result ContextVk::updateScissor(const gl::State &glState)
// a render pass, the scissor is disabled and a draw call is issued to affect the whole // a render pass, the scissor is disabled and a draw call is issued to affect the whole
// framebuffer. // framebuffer.
gl::Rectangle scissoredRenderArea = framebufferVk->getRotatedScissoredRenderArea(this); gl::Rectangle scissoredRenderArea = framebufferVk->getRotatedScissoredRenderArea(this);
if (mRenderPassCommands->started()) if (shouldEndRenderPass && mRenderPassCommands->started())
{ {
if (!mRenderPassCommands->getRenderArea().encloses(scissoredRenderArea)) if (!mRenderPassCommands->getRenderArea().encloses(scissoredRenderArea))
{ {
...@@ -2794,7 +2794,7 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2794,7 +2794,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
{ {
case gl::State::DIRTY_BIT_SCISSOR_TEST_ENABLED: case gl::State::DIRTY_BIT_SCISSOR_TEST_ENABLED:
case gl::State::DIRTY_BIT_SCISSOR: case gl::State::DIRTY_BIT_SCISSOR:
ANGLE_TRY(updateScissor(glState)); ANGLE_TRY(updateScissorAndEndRenderPass(glState));
break; break;
case gl::State::DIRTY_BIT_VIEWPORT: case gl::State::DIRTY_BIT_VIEWPORT:
{ {
...@@ -2802,7 +2802,7 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2802,7 +2802,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
updateViewport(framebufferVk, glState.getViewport(), glState.getNearPlane(), updateViewport(framebufferVk, glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(), isViewportFlipEnabledForDrawFBO()); glState.getFarPlane(), isViewportFlipEnabledForDrawFBO());
// Update the scissor, which will be constrained to the viewport // Update the scissor, which will be constrained to the viewport
ANGLE_TRY(updateScissor(glState)); ANGLE_TRY(updateScissorAndEndRenderPass(glState));
break; break;
} }
case gl::State::DIRTY_BIT_DEPTH_RANGE: case gl::State::DIRTY_BIT_DEPTH_RANGE:
......
...@@ -469,7 +469,14 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -469,7 +469,14 @@ class ContextVk : public ContextImpl, public vk::Context
// avoid calling vkAllocateDesctiporSets each texture update. // avoid calling vkAllocateDesctiporSets each texture update.
const vk::TextureDescriptorDesc &getActiveTexturesDesc() const { return mActiveTexturesDesc; } const vk::TextureDescriptorDesc &getActiveTexturesDesc() const { return mActiveTexturesDesc; }
angle::Result updateScissor(const gl::State &glState); angle::Result updateScissor(const gl::State &glState)
{
return updateScissorImpl(glState, false);
}
angle::Result updateScissorAndEndRenderPass(const gl::State &glState)
{
return updateScissorImpl(glState, true);
}
bool emulateSeamfulCubeMapSampling() const { return mEmulateSeamfulCubeMapSampling; } bool emulateSeamfulCubeMapSampling() const { return mEmulateSeamfulCubeMapSampling; }
...@@ -879,6 +886,8 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -879,6 +886,8 @@ class ContextVk : public ContextImpl, public vk::Context
template <typename T, const T *VkWriteDescriptorSet::*pInfo> template <typename T, const T *VkWriteDescriptorSet::*pInfo>
void growDesciptorCapacity(std::vector<T> *descriptorVector, size_t newSize); void growDesciptorCapacity(std::vector<T> *descriptorVector, size_t newSize);
angle::Result updateScissorImpl(const gl::State &glState, bool shouldEndRenderPass);
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers;
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers;
......
...@@ -295,7 +295,7 @@ TEST_P(FramebufferFormatsTest, IncompleteCubeMap) ...@@ -295,7 +295,7 @@ TEST_P(FramebufferFormatsTest, IncompleteCubeMap)
mTexture, 0); mTexture, 0);
// Verify the framebuffer is complete. // Verify the framebuffer is complete.
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Make the CubeMap cube-incomplete. // Make the CubeMap cube-incomplete.
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
...@@ -583,7 +583,7 @@ TEST_P(FramebufferTest_ES3, MultisampleDepthOnly) ...@@ -583,7 +583,7 @@ TEST_P(FramebufferTest_ES3, MultisampleDepthOnly)
GLFramebuffer framebuffer; GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
GLint samples = 0; GLint samples = 0;
...@@ -607,7 +607,7 @@ TEST_P(FramebufferTest_ES3, AttachmentWith3DLayers) ...@@ -607,7 +607,7 @@ TEST_P(FramebufferTest_ES3, AttachmentWith3DLayers)
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texA, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texA, 0);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, texB, 0, 0); glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, texB, 0, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
...@@ -743,7 +743,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentSmallToLarge) ...@@ -743,7 +743,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentSmallToLarge)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the small texture // Draw to FBO backed by the small texture
glUseProgram(greenProgram); glUseProgram(greenProgram);
...@@ -759,7 +759,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentSmallToLarge) ...@@ -759,7 +759,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentSmallToLarge)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the large texture // Draw to FBO backed by the large texture
glUseProgram(blueProgram); glUseProgram(blueProgram);
...@@ -788,7 +788,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentLargeToSmall) ...@@ -788,7 +788,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentLargeToSmall)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the large texture // Draw to FBO backed by the large texture
glUseProgram(blueProgram); glUseProgram(blueProgram);
...@@ -804,7 +804,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentLargeToSmall) ...@@ -804,7 +804,7 @@ TEST_P(FramebufferTest_ES3, ResizeColorAttachmentLargeToSmall)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the small texture // Draw to FBO backed by the small texture
glUseProgram(greenProgram); glUseProgram(greenProgram);
...@@ -832,7 +832,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureLargeToSmall) ...@@ -832,7 +832,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureLargeToSmall)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the large texture // Draw to FBO backed by the large texture
glUseProgram(blueProgram); glUseProgram(blueProgram);
...@@ -848,7 +848,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureLargeToSmall) ...@@ -848,7 +848,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureLargeToSmall)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the small texture // Draw to FBO backed by the small texture
glUseProgram(greenProgram); glUseProgram(greenProgram);
...@@ -876,7 +876,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureSmallToLarge) ...@@ -876,7 +876,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureSmallToLarge)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the large texture // Draw to FBO backed by the large texture
glUseProgram(blueProgram); glUseProgram(blueProgram);
...@@ -892,7 +892,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureSmallToLarge) ...@@ -892,7 +892,7 @@ TEST_P(FramebufferTest_ES3, ResizeTextureSmallToLarge)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw to FBO backed by the small texture // Draw to FBO backed by the small texture
glUseProgram(greenProgram); glUseProgram(greenProgram);
...@@ -1536,7 +1536,7 @@ void main() { ...@@ -1536,7 +1536,7 @@ void main() {
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
// Texture is still a valid name in context2. // Texture is still a valid name in context2.
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// There is no rendering feedback loop at this point. // There is no rendering feedback loop at this point.
glDisable(GL_BLEND); glDisable(GL_BLEND);
...@@ -1579,6 +1579,72 @@ TEST_P(FramebufferTest, IncompleteCubeMap) ...@@ -1579,6 +1579,72 @@ TEST_P(FramebufferTest, IncompleteCubeMap)
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT); GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
} }
// Test FBOs with different sizes are drawn correctly
TEST_P(FramebufferTest, BindAndDrawDifferentSizedFBOs)
{
// 1. Create FBO 1 with dimensions 16x16
// 2. Draw red into FBO 1 (note, FramebufferVk::syncState is called)
// 3. Create FBO 2 with dimensions 8x8
// 4. Draw green into FBO 2 (note, FramebufferVk::syncState is called)
// 5. Bind FBO 1 (note, it's not dirty)
// 6. Draw blue into FBO 1
// 7. Verify FBO 1 is entirely blue
GLFramebuffer smallFbo;
GLFramebuffer largeFbo;
GLTexture smallTexture;
GLTexture largeTexture;
constexpr GLsizei kLargeWidth = 16;
constexpr GLsizei kLargeHeight = 16;
constexpr GLsizei kSmallWidth = 8;
constexpr GLsizei kSmallHeight = 8;
ANGLE_GL_PROGRAM(redProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
ANGLE_GL_PROGRAM(greenProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green());
ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue());
// 1. Create FBO 1 with dimensions 16x16
glBindFramebuffer(GL_FRAMEBUFFER, largeFbo);
glBindTexture(GL_TEXTURE_2D, largeTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kLargeWidth, kLargeHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0);
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// 2. Draw red into FBO 1 (note, FramebufferVk::syncState is called)
glUseProgram(redProgram);
drawQuad(redProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f);
ASSERT_GL_NO_ERROR();
// 3. Create FBO 2 with dimensions 8x8
glBindFramebuffer(GL_FRAMEBUFFER, smallFbo);
glBindTexture(GL_TEXTURE_2D, smallTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSmallWidth, kSmallHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0);
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// 4. Draw green into FBO 2 (note, FramebufferVk::syncState is called)
glUseProgram(greenProgram);
drawQuad(greenProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f);
ASSERT_GL_NO_ERROR();
// 5. Bind FBO 1 (note, it's not dirty)
glBindFramebuffer(GL_FRAMEBUFFER, largeFbo);
// 6. Draw blue into FBO 1
glUseProgram(blueProgram);
drawQuad(blueProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f);
ASSERT_GL_NO_ERROR();
// 7. Verify FBO 1 is entirely blue
EXPECT_PIXEL_RECT_EQ(0, 0, kLargeWidth, kLargeHeight, GLColor::blue);
}
ANGLE_INSTANTIATE_TEST_ES2(AddDummyTextureNoRenderTargetTest); ANGLE_INSTANTIATE_TEST_ES2(AddDummyTextureNoRenderTargetTest);
ANGLE_INSTANTIATE_TEST_ES2(FramebufferTest); ANGLE_INSTANTIATE_TEST_ES2(FramebufferTest);
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(FramebufferFormatsTest); ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(FramebufferFormatsTest);
......
...@@ -238,9 +238,9 @@ void LoadEntryPointsWithUtilLoader(angle::GLESDriverType driver); ...@@ -238,9 +238,9 @@ void LoadEntryPointsWithUtilLoader(angle::GLESDriverType driver);
#define EXPECT_PIXEL_RECT_EQ(x, y, width, height, color) \ #define EXPECT_PIXEL_RECT_EQ(x, y, width, height, color) \
do \ do \
{ \ { \
std::vector<GLColor> actualColors(width *height); \ std::vector<GLColor> actualColors((width) * (height)); \
glReadPixels((x), (y), (width), (height), GL_RGBA, GL_UNSIGNED_BYTE, actualColors.data()); \ glReadPixels((x), (y), (width), (height), GL_RGBA, GL_UNSIGNED_BYTE, actualColors.data()); \
std::vector<GLColor> expectedColors(width *height, color); \ std::vector<GLColor> expectedColors((width) * (height), color); \
EXPECT_EQ(expectedColors, actualColors); \ EXPECT_EQ(expectedColors, actualColors); \
} while (0) } while (0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment