Commit 1c881dad by Le Hoang Quyen Committed by Commit Bot

Metal: Implement glRenderbufferStorageMultisample(ANGLE)

Bug: angleproject:2634 Change-Id: Ia4dd477cfbad298994036705b43f3a5877e3c9cc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433330 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 80d4901a
...@@ -515,10 +515,11 @@ void DisplayMtl::ensureCapsInitialized() const ...@@ -515,10 +515,11 @@ void DisplayMtl::ensureCapsInitialized() const
mNativeCaps.maxViewportWidth = mNativeCaps.max2DTextureSize; mNativeCaps.maxViewportWidth = mNativeCaps.max2DTextureSize;
mNativeCaps.maxViewportHeight = mNativeCaps.max2DTextureSize; mNativeCaps.maxViewportHeight = mNativeCaps.max2DTextureSize;
// NOTE(hqle): MSAA // MSAA
mNativeCaps.maxSamples = mFormatTable.getMaxSamples();
mNativeCaps.maxSampleMaskWords = 0; mNativeCaps.maxSampleMaskWords = 0;
mNativeCaps.maxColorTextureSamples = 1; mNativeCaps.maxColorTextureSamples = mNativeCaps.maxSamples;
mNativeCaps.maxDepthTextureSamples = 1; mNativeCaps.maxDepthTextureSamples = mNativeCaps.maxSamples;
mNativeCaps.maxIntegerSamples = 1; mNativeCaps.maxIntegerSamples = 1;
mNativeCaps.maxVertexAttributes = mtl::kMaxVertexAttribs; mNativeCaps.maxVertexAttributes = mtl::kMaxVertexAttribs;
...@@ -597,9 +598,6 @@ void DisplayMtl::ensureCapsInitialized() const ...@@ -597,9 +598,6 @@ void DisplayMtl::ensureCapsInitialized() const
mNativeCaps.maxTransformFeedbackSeparateComponents = mNativeCaps.maxTransformFeedbackSeparateComponents =
gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS; gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS;
// NOTE(hqle): support MSAA.
mNativeCaps.maxSamples = 1;
// GL_APPLE_clip_distance // GL_APPLE_clip_distance
mNativeCaps.maxClipDistances = 8; mNativeCaps.maxClipDistances = 8;
} }
...@@ -617,7 +615,7 @@ void DisplayMtl::initializeExtensions() const ...@@ -617,7 +615,7 @@ void DisplayMtl::initializeExtensions() const
mNativeExtensions.drawBuffers = true; mNativeExtensions.drawBuffers = true;
mNativeExtensions.fragDepth = true; mNativeExtensions.fragDepth = true;
mNativeExtensions.framebufferBlit = true; mNativeExtensions.framebufferBlit = true;
mNativeExtensions.framebufferMultisample = false; mNativeExtensions.framebufferMultisample = true;
mNativeExtensions.copyTexture = true; mNativeExtensions.copyTexture = true;
mNativeExtensions.copyCompressedTexture = false; mNativeExtensions.copyCompressedTexture = false;
......
...@@ -38,14 +38,12 @@ angle::Result RenderbufferMtl::setStorageImpl(const gl::Context *context, ...@@ -38,14 +38,12 @@ angle::Result RenderbufferMtl::setStorageImpl(const gl::Context *context,
{ {
ContextMtl *contextMtl = mtl::GetImpl(context); ContextMtl *contextMtl = mtl::GetImpl(context);
// NOTE(hqle): Support MSAA
ANGLE_CHECK(contextMtl, samples == 1, "Multisample is not supported atm.", GL_INVALID_VALUE);
if (mTexture != nullptr && mTexture->valid()) if (mTexture != nullptr && mTexture->valid())
{ {
// Check against the state if we need to recreate the storage. // Check against the state if we need to recreate the storage.
if (internalformat != mState.getFormat().info->internalFormat || if (internalformat != mState.getFormat().info->internalFormat ||
width != mState.getWidth() || height != mState.getHeight()) width != mState.getWidth() || height != mState.getHeight() ||
samples != mState.getSamples())
{ {
releaseTexture(); releaseTexture();
} }
...@@ -56,10 +54,36 @@ angle::Result RenderbufferMtl::setStorageImpl(const gl::Context *context, ...@@ -56,10 +54,36 @@ angle::Result RenderbufferMtl::setStorageImpl(const gl::Context *context,
angle::Format::InternalFormatToID(internalFormat.sizedInternalFormat); angle::Format::InternalFormatToID(internalFormat.sizedInternalFormat);
mFormat = contextMtl->getPixelFormat(angleFormatId); mFormat = contextMtl->getPixelFormat(angleFormatId);
uint32_t actualSamples;
if (samples == 0)
{
actualSamples = 1;
}
else
{
// We always start at at least 2 samples
actualSamples = static_cast<uint32_t>(std::max<size_t>(2, samples));
const gl::TextureCaps &textureCaps =
contextMtl->getTextureCaps().get(mFormat.intendedFormatId);
actualSamples = textureCaps.getNearestSamples(actualSamples);
ANGLE_MTL_CHECK(contextMtl, actualSamples != 0, GL_INVALID_VALUE);
}
if ((mTexture == nullptr || !mTexture->valid()) && (width != 0 && height != 0)) if ((mTexture == nullptr || !mTexture->valid()) && (width != 0 && height != 0))
{ {
ANGLE_TRY(mtl::Texture::Make2DTexture(contextMtl, mFormat, width, height, 1, false, if (actualSamples == 1)
mFormat.hasDepthAndStencilBits(), &mTexture)); {
ANGLE_TRY(mtl::Texture::Make2DTexture(contextMtl, mFormat, width, height, 1, false,
mFormat.hasDepthAndStencilBits(), &mTexture));
}
else
{
ANGLE_TRY(mtl::Texture::Make2DMSTexture(
contextMtl, mFormat, width, height, actualSamples,
/* renderTargetOnly */ false,
/* allowFormatView */ mFormat.hasDepthAndStencilBits(), &mTexture));
}
mRenderTarget.set(mTexture, mtl::kZeroNativeMipLevel, 0, mFormat); mRenderTarget.set(mTexture, mtl::kZeroNativeMipLevel, 0, mFormat);
...@@ -82,7 +106,7 @@ angle::Result RenderbufferMtl::setStorage(const gl::Context *context, ...@@ -82,7 +106,7 @@ angle::Result RenderbufferMtl::setStorage(const gl::Context *context,
GLsizei width, GLsizei width,
GLsizei height) GLsizei height)
{ {
return setStorageImpl(context, 1, internalformat, width, height); return setStorageImpl(context, 0, internalformat, width, height);
} }
angle::Result RenderbufferMtl::setStorageMultisample(const gl::Context *context, angle::Result RenderbufferMtl::setStorageMultisample(const gl::Context *context,
...@@ -92,9 +116,7 @@ angle::Result RenderbufferMtl::setStorageMultisample(const gl::Context *context, ...@@ -92,9 +116,7 @@ angle::Result RenderbufferMtl::setStorageMultisample(const gl::Context *context,
GLsizei height, GLsizei height,
gl::MultisamplingMode mode) gl::MultisamplingMode mode)
{ {
// NOTE(hqle): Support MSAA return setStorageImpl(context, samples, internalformat, width, height);
UNIMPLEMENTED();
return angle::Result::Stop;
} }
angle::Result RenderbufferMtl::setStorageEGLImageTarget(const gl::Context *context, angle::Result RenderbufferMtl::setStorageEGLImageTarget(const gl::Context *context,
......
...@@ -1231,6 +1231,9 @@ TEST_P(BlitFramebufferTest, BlitMultisampleStencilToDefault) ...@@ -1231,6 +1231,9 @@ TEST_P(BlitFramebufferTest, BlitMultisampleStencilToDefault)
// http://anglebug.com/3496 // http://anglebug.com/3496
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX()); ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX());
// http://anglebug.com/5106
ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel() && IsOSX());
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
...@@ -1360,6 +1363,9 @@ TEST_P(BlitFramebufferTest, MultisampleStencil) ...@@ -1360,6 +1363,9 @@ TEST_P(BlitFramebufferTest, MultisampleStencil)
// Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486 // Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486
ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows()); ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows());
// http://anglebug.com/5106
ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel() && IsOSX());
GLRenderbuffer renderbuf; GLRenderbuffer renderbuf;
glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get()); glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256); glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256);
...@@ -1616,6 +1622,9 @@ TEST_P(BlitFramebufferTest, NonZeroBaseSourceStencil) ...@@ -1616,6 +1622,9 @@ TEST_P(BlitFramebufferTest, NonZeroBaseSourceStencil)
// http://anglebug.com/5001 // http://anglebug.com/5001
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX()); ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX());
// http://anglebug.com/5106
ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel() && IsOSX());
ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red()); ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
// Create a framebuffer with an attachment that has non-zero base // Create a framebuffer with an attachment that has non-zero base
...@@ -1679,6 +1688,8 @@ TEST_P(BlitFramebufferTest, NonZeroBaseDestinationStencil) ...@@ -1679,6 +1688,8 @@ TEST_P(BlitFramebufferTest, NonZeroBaseDestinationStencil)
{ {
// http://anglebug.com/5001 // http://anglebug.com/5001
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX()); ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX());
// http://anglebug.com/5106
ANGLE_SKIP_TEST_IF(IsMetal() && (IsAMD() || IsIntel()));
// http://anglebug.com/5003 // http://anglebug.com/5003
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsWindows()); ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsWindows());
...@@ -1750,6 +1761,9 @@ TEST_P(BlitFramebufferTest, NonZeroBaseDestinationStencilStretch) ...@@ -1750,6 +1761,9 @@ TEST_P(BlitFramebufferTest, NonZeroBaseDestinationStencilStretch)
// http://anglebug.com/5001 // http://anglebug.com/5001
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX()); ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX());
// http://anglebug.com/5106
ANGLE_SKIP_TEST_IF(IsMetal() && (IsAMD() || IsIntel()));
ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red()); ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
// Create a framebuffer for source data. // Create a framebuffer for source data.
...@@ -1867,6 +1881,9 @@ TEST_P(BlitFramebufferTest, BlitSRGBToRGBAndScale) ...@@ -1867,6 +1881,9 @@ TEST_P(BlitFramebufferTest, BlitSRGBToRGBAndScale)
// Blit stencil, with scissor and scale it. // Blit stencil, with scissor and scale it.
TEST_P(BlitFramebufferTest, BlitStencilScissoredScaled) TEST_P(BlitFramebufferTest, BlitStencilScissoredScaled)
{ {
// http://anglebug.com/5106
ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel() && IsOSX());
constexpr GLint kSize = 256; constexpr GLint kSize = 256;
// Create the destination framebuffer. // Create the destination framebuffer.
...@@ -2373,4 +2390,6 @@ ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest, ...@@ -2373,4 +2390,6 @@ ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest,
ES2_METAL(), ES2_METAL(),
WithNoShaderStencilOutput(ES2_METAL())); WithNoShaderStencilOutput(ES2_METAL()));
ANGLE_INSTANTIATE_TEST_ES3(BlitFramebufferTest); ANGLE_INSTANTIATE_TEST_ES3_AND(BlitFramebufferTest,
ES3_METAL(),
WithNoShaderStencilOutput(ES3_METAL()));
...@@ -2510,5 +2510,5 @@ TEST_P(FramebufferTest, BindAndDrawDifferentSizedFBOs) ...@@ -2510,5 +2510,5 @@ TEST_P(FramebufferTest, BindAndDrawDifferentSizedFBOs)
ANGLE_INSTANTIATE_TEST_ES2(AddMockTextureNoRenderTargetTest); ANGLE_INSTANTIATE_TEST_ES2(AddMockTextureNoRenderTargetTest);
ANGLE_INSTANTIATE_TEST_ES2(FramebufferTest); ANGLE_INSTANTIATE_TEST_ES2(FramebufferTest);
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(FramebufferFormatsTest); ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(FramebufferFormatsTest);
ANGLE_INSTANTIATE_TEST_ES3(FramebufferTest_ES3); ANGLE_INSTANTIATE_TEST_ES3_AND(FramebufferTest_ES3, ES3_METAL());
ANGLE_INSTANTIATE_TEST_ES31(FramebufferTest_ES31); ANGLE_INSTANTIATE_TEST_ES31(FramebufferTest_ES31);
...@@ -509,5 +509,6 @@ ANGLE_INSTANTIATE_TEST_COMBINE_1(MultisampleTestES3, ...@@ -509,5 +509,6 @@ ANGLE_INSTANTIATE_TEST_COMBINE_1(MultisampleTestES3,
WithNoFixture(ES3_OPENGLES()), WithNoFixture(ES3_OPENGLES()),
WithNoFixture(ES31_OPENGLES()), WithNoFixture(ES31_OPENGLES()),
WithNoFixture(ES3_VULKAN()), WithNoFixture(ES3_VULKAN()),
WithNoFixture(ES31_VULKAN())); WithNoFixture(ES31_VULKAN()),
WithNoFixture(ES3_METAL()));
} // anonymous namespace } // anonymous namespace
...@@ -123,5 +123,5 @@ TEST_P(RenderbufferMultisampleTest, OddSampleCount) ...@@ -123,5 +123,5 @@ TEST_P(RenderbufferMultisampleTest, OddSampleCount)
} }
} }
ANGLE_INSTANTIATE_TEST_ES3_AND_ES31(RenderbufferMultisampleTest); ANGLE_INSTANTIATE_TEST_ES3_AND_ES31_AND(RenderbufferMultisampleTest, ES3_METAL());
} // namespace } // namespace
...@@ -165,9 +165,9 @@ struct CombinedPrintToStringParamName ...@@ -165,9 +165,9 @@ struct CombinedPrintToStringParamName
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
#define ANGLE_INSTANTIATE_TEST_ES3_AND(testName, extra) \ #define ANGLE_INSTANTIATE_TEST_ES3_AND(testName, ...) \
const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES3, extra}; \ const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES3, __VA_ARGS__}; \
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
// Instantiate the test once for each GLES31 platform // Instantiate the test once for each GLES31 platform
...@@ -176,9 +176,9 @@ struct CombinedPrintToStringParamName ...@@ -176,9 +176,9 @@ struct CombinedPrintToStringParamName
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
#define ANGLE_INSTANTIATE_TEST_ES31_AND(testName, extra) \ #define ANGLE_INSTANTIATE_TEST_ES31_AND(testName, ...) \
const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES31, extra}; \ const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES31, __VA_ARGS__}; \
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
// Multiple ES Version macros // Multiple ES Version macros
...@@ -188,10 +188,10 @@ struct CombinedPrintToStringParamName ...@@ -188,10 +188,10 @@ struct CombinedPrintToStringParamName
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
#define ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND(testName, extra) \ #define ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND(testName, ...) \
const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES2, \ const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES2, \
ANGLE_ALL_TEST_PLATFORMS_ES3, extra}; \ ANGLE_ALL_TEST_PLATFORMS_ES3, __VA_ARGS__}; \
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
#define ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND_ES31(testName) \ #define ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND_ES31(testName) \
...@@ -214,6 +214,12 @@ struct CombinedPrintToStringParamName ...@@ -214,6 +214,12 @@ struct CombinedPrintToStringParamName
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName()) testing::PrintToStringParamName())
#define ANGLE_INSTANTIATE_TEST_ES3_AND_ES31_AND(testName, ...) \
const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES3, \
ANGLE_ALL_TEST_PLATFORMS_ES31, __VA_ARGS__}; \
INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \
testing::PrintToStringParamName())
// Instantiate the test for a combination of N parameters and the // Instantiate the test for a combination of N parameters and the
// enumeration of platforms in the extra args, similar to // enumeration of platforms in the extra args, similar to
// ANGLE_INSTANTIATE_TEST. The macros are defined only for the Ns // ANGLE_INSTANTIATE_TEST. The macros are defined only for the Ns
......
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