Skip to content

Commit

Permalink
add ext_float_blend feature and test
Browse files Browse the repository at this point in the history
Bug: chromium:930993
Change-Id: I8edbd01c5c9f1ed63243cc4a42f6de44c92db8bd
Reviewed-on: https://chromium-review.googlesource.com/c/1481242
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Jamie Madill <jmadill@google.com>
  • Loading branch information
shrekshao authored and Commit Bot committed Feb 28, 2019
1 parent dbbdf56 commit c87e005
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libANGLE/Caps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ Extensions::Extensions()
multiviewMultisample(false),
blendFuncExtended(false),
maxDualSourceDrawBuffers(0),
floatBlend(false),
memorySize(false),
textureMultisample(false),
multiDraw(false)
Expand Down Expand Up @@ -909,6 +910,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_texture_storage_multisample_2d_array"] = enableableExtension(&Extensions::textureStorageMultisample2DArray);
map["GL_ANGLE_multiview_multisample"] = enableableExtension(&Extensions::multiviewMultisample);
map["GL_EXT_blend_func_extended"] = enableableExtension(&Extensions::blendFuncExtended);
map["GL_EXT_float_blend"] = enableableExtension(&Extensions::floatBlend);
map["GL_ANGLE_texture_multisample"] = enableableExtension(&Extensions::textureMultisample);
map["GL_ANGLE_multi_draw"] = enableableExtension(&Extensions::multiDraw);
map["GL_ANGLE_provoking_vertex"] = enableableExtension(&Extensions::provokingVertex);
Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/Caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ struct Extensions
bool blendFuncExtended;
GLuint maxDualSourceDrawBuffers;

// GL_EXT_float_blend
bool floatBlend;

// GL_ANGLE_memory_size
bool memorySize;

Expand Down
1 change: 1 addition & 0 deletions src/libANGLE/ErrorStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ MSG kUnimplementedComputeShaderPrecision = "Compute shader precision not yet imp
MSG kUnknownParameter = "Unknown parameter value.";
MSG kUnsizedInternalFormatUnsupported = "Internalformat is one of the unsupported unsized base internalformats.";
MSG kUnsupportedDrawModeForTransformFeedback = "The draw command is unsupported when transform feedback is active and not paused.";
MSG kUnsupportedFloatBlending = "GL_BLEND with floating-point color attachments requires the EXT_float_blend extension.";
MSG kVertexArrayNoBuffer = "An enabled vertex array has no buffer.";
MSG kVertexArrayNoBufferPointer = "An enabled vertex array has no buffer and no pointer.";
MSG kVertexBufferBoundForTransformFeedback = "It is undefined behavior to use a vertex buffer that is bound for transform feedback.";
Expand Down
19 changes: 19 additions & 0 deletions src/libANGLE/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,16 @@ void Framebuffer::setAttachmentImpl(const Context *context,
textureIndex, resource, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);

if (!resource)
{
mFloat32ColorAttachmentBits.reset(colorIndex);
}
else
{
updateFloat32ColorAttachmentBits(
colorIndex, resource->getAttachmentFormat(binding, textureIndex).info);
}

// TODO(jmadill): ASSERT instead of checking the attachment exists in
// formsRenderingFeedbackLoopWith
bool enabled = (type != GL_NONE && getDrawBufferState(colorIndex) != GL_NONE);
Expand Down Expand Up @@ -1829,6 +1839,15 @@ void Framebuffer::onSubjectStateChange(const Context *context,

// Mark the appropriate init flag.
mState.mResourceNeedsInit.set(index, attachment->initState() == InitState::MayNeedInit);

// Update mFloat32ColorAttachmentBits Cache
if (index < DIRTY_BIT_COLOR_ATTACHMENT_MAX)
{
ASSERT(index != DIRTY_BIT_DEPTH_ATTACHMENT);
ASSERT(index != DIRTY_BIT_STENCIL_ATTACHMENT);
updateFloat32ColorAttachmentBits(index - DIRTY_BIT_COLOR_ATTACHMENT_0,
attachment->getFormat().info);
}
}

FramebufferAttachment *Framebuffer::getAttachmentFromSubjectIndex(angle::SubjectIndex index)
Expand Down
12 changes: 12 additions & 0 deletions src/libANGLE/Framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ class Framebuffer final : public angle::ObserverInterface,
using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
bool hasAnyDirtyBit() const { return mDirtyBits.any(); }

bool hasActiveFloat32ColorAttachment() const
{
return (mFloat32ColorAttachmentBits & getDrawBufferMask()).any();
}

bool hasResourceThatNeedsInit() const { return mState.mResourceNeedsInit.any(); }

angle::Result syncState(const Context *context);
Expand Down Expand Up @@ -418,6 +423,12 @@ class Framebuffer final : public angle::ObserverInterface,

FramebufferAttachment *getAttachmentFromSubjectIndex(angle::SubjectIndex index);

ANGLE_INLINE void updateFloat32ColorAttachmentBits(size_t index,
const gl::InternalFormat *format)
{
mFloat32ColorAttachmentBits.set(index, format->type == GL_FLOAT);
}

FramebufferState mState;
rx::FramebufferImpl *mImpl;

Expand All @@ -427,6 +438,7 @@ class Framebuffer final : public angle::ObserverInterface,
angle::ObserverBinding mDirtyStencilAttachmentBinding;

DirtyBits mDirtyBits;
DrawBufferMask mFloat32ColorAttachmentBits;

// The dirty bits guard is checked when we get a dependent state change message. We verify that
// we don't set a dirty bit that isn't already set, when inside the dirty bits syncState.
Expand Down
5 changes: 5 additions & 0 deletions src/libANGLE/renderer/gl/renderergl_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,11 @@ void GenerateCaps(const FunctionsGL *functions,
extensions->maxDualSourceDrawBuffers = 1;
}

// EXT_float_blend
// Assume all desktop driver supports this by default.
extensions->floatBlend = functions->standard == STANDARD_GL_DESKTOP ||
functions->hasGLESExtension("GL_EXT_float_blend");

// GL_CHROMIUM_compressed_texture_etc
// Expose this extension only when we support the formats or we're running on top of a native
// ES driver.
Expand Down
6 changes: 6 additions & 0 deletions src/libANGLE/validationES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2623,6 +2623,12 @@ const char *ValidateDrawStates(Context *context)
}
}

if (!extensions.floatBlend && context->getState().isBlendEnabled() &&
framebuffer->hasActiveFloat32ColorAttachment())
{
return kUnsupportedFloatBlending;
}

if (!framebuffer->isComplete(context))
{
// Note: this error should be generated as INVALID_FRAMEBUFFER_OPERATION.
Expand Down
2 changes: 1 addition & 1 deletion src/tests/gl_tests/BlendMinMaxTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ TEST_P(BlendMinMaxTest, RGBA8)

TEST_P(BlendMinMaxTest, RGBA32F)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 ||
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 || !extensionEnabled("GL_EXT_float_blend") ||
!extensionEnabled("GL_EXT_color_buffer_float"));

// Ignore SDK layers messages on D3D11 FL 9.3 (http://anglebug.com/1284)
Expand Down
Loading

0 comments on commit c87e005

Please sign in to comment.