Commit f6e160fa by Luc Ferron Committed by Commit Bot

Vulkan: Don't use swizzle state when its not needed

Enables a bunch of dEQP tests in the functional.fbo.render.* namespace. Bug: angleproject:2597 Change-Id: I1a06b335d5daf2987df52c460903081860887ce9 Reviewed-on: https://chromium-review.googlesource.com/1097596 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent d668be9c
......@@ -174,6 +174,7 @@ gl::Error ContextVk::setupDraw(const gl::Context *context,
{
mTexturesDirty = false;
// TODO(jmadill): Should probably merge this for loop with programVk's descriptor update.
ContextVk *contextVk = vk::GetImpl(context);
const auto &completeTextures = state.getCompleteTextureCache();
for (const gl::SamplerBinding &samplerBinding : programGL->getSamplerBindings())
{
......@@ -190,7 +191,7 @@ gl::Error ContextVk::setupDraw(const gl::Context *context,
}
TextureVk *textureVk = vk::GetImpl(texture);
ANGLE_TRY(textureVk->ensureImageInitialized(mRenderer));
ANGLE_TRY(textureVk->ensureImageInitialized(contextVk));
textureVk->addReadDependency(framebufferVk);
}
}
......
......@@ -533,13 +533,24 @@ gl::Error FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
if (clearColor)
{
RenderTargetVk *renderTarget = getColorReadRenderTarget();
const vk::Format &format = renderTarget->getImageFormat();
VkClearValue modifiedClear = contextVk->getClearColorValue();
// We need to make sure we are not clearing the alpha channel if we are using a buffer
// format that doesn't have an alpha channel.
if (format.angleFormat().alphaBits == 0)
{
modifiedClear.color.float32[3] = 1.0;
}
// TODO(jmadill): Support gaps in RenderTargets. http://anglebug.com/2394
for (size_t colorIndex : mState.getEnabledDrawBuffers())
{
VkClearAttachment &clearAttachment = clearAttachments[clearAttachmentIndex];
clearAttachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
clearAttachment.colorAttachment = static_cast<uint32_t>(colorIndex);
clearAttachment.clearValue = contextVk->getClearColorValue();
clearAttachment.clearValue = modifiedClear;
++clearAttachmentIndex;
}
}
......
......@@ -45,12 +45,6 @@ void MapSwizzleState(GLenum internalFormat,
swizzleStateOut->swizzleBlue = GL_ZERO;
swizzleStateOut->swizzleAlpha = swizzleState.swizzleRed;
break;
case GL_RGB8:
swizzleStateOut->swizzleRed = swizzleState.swizzleRed;
swizzleStateOut->swizzleGreen = swizzleState.swizzleGreen;
swizzleStateOut->swizzleBlue = swizzleState.swizzleBlue;
swizzleStateOut->swizzleAlpha = GL_ONE;
break;
default:
*swizzleStateOut = swizzleState;
break;
......@@ -612,7 +606,7 @@ gl::Error TextureVk::setStorage(const gl::Context *context,
const vk::Format &format = renderer->getFormat(internalFormat);
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(getCommandBufferForWrite(renderer, &commandBuffer));
ANGLE_TRY(initImage(renderer, format, size, static_cast<uint32_t>(levels), commandBuffer));
ANGLE_TRY(initImage(contextVk, format, size, static_cast<uint32_t>(levels), commandBuffer));
return gl::NoError();
}
......@@ -784,7 +778,6 @@ gl::Error TextureVk::generateMipmapWithCPU(const gl::Context *context)
gl::Error TextureVk::generateMipmap(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
// Some data is pending, or the image has not been defined at all yet
if (!mImage.valid())
......@@ -792,7 +785,7 @@ gl::Error TextureVk::generateMipmap(const gl::Context *context)
// lets initialize the image so we can generate the next levels.
if (!mPixelBuffer.empty())
{
ANGLE_TRY(ensureImageInitialized(renderer));
ANGLE_TRY(ensureImageInitialized(contextVk));
ASSERT(mImage.valid());
}
else
......@@ -802,6 +795,7 @@ gl::Error TextureVk::generateMipmap(const gl::Context *context)
}
}
RendererVk *renderer = contextVk->getRenderer();
VkFormatProperties imageProperties;
vk::GetFormatProperties(renderer->getPhysicalDevice(), mImage.getFormat().vkTextureFormat,
&imageProperties);
......@@ -853,21 +847,19 @@ gl::Error TextureVk::getAttachmentRenderTarget(const gl::Context *context,
ASSERT(imageIndex.getLevelIndex() == 0 && !imageIndex.hasLayer());
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
ANGLE_TRY(ensureImageInitialized(renderer));
ANGLE_TRY(ensureImageInitialized(contextVk));
*rtOut = &mRenderTarget;
return gl::NoError();
}
vk::Error TextureVk::ensureImageInitialized(RendererVk *renderer)
vk::Error TextureVk::ensureImageInitialized(ContextVk *contextVk)
{
if (mImage.valid() && mPixelBuffer.empty())
{
return vk::NoError();
}
RendererVk *renderer = contextVk->getRenderer();
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(getCommandBufferForWrite(renderer, &commandBuffer));
......@@ -880,7 +872,7 @@ vk::Error TextureVk::ensureImageInitialized(RendererVk *renderer)
const vk::Format &format =
renderer->getFormat(baseLevelDesc.format.info->sizedInternalFormat);
ANGLE_TRY(initImage(renderer, format, baseLevelExtents, levelCount, commandBuffer));
ANGLE_TRY(initImage(contextVk, format, baseLevelExtents, levelCount, commandBuffer));
}
ANGLE_TRY(mPixelBuffer.flushUpdatesToImage(renderer, levelCount, &mImage, commandBuffer));
......@@ -971,12 +963,13 @@ const vk::Sampler &TextureVk::getSampler() const
return mSampler;
}
vk::Error TextureVk::initImage(RendererVk *renderer,
vk::Error TextureVk::initImage(ContextVk *contextVk,
const vk::Format &format,
const gl::Extents &extents,
const uint32_t levelCount,
vk::CommandBuffer *commandBuffer)
{
const RendererVk *renderer = contextVk->getRenderer();
const VkDevice device = renderer->getDevice();
const VkImageUsageFlags usage =
......@@ -992,6 +985,10 @@ vk::Error TextureVk::initImage(RendererVk *renderer,
gl::SwizzleState mappedSwizzle;
MapSwizzleState(format.internalFormat, mState.getSwizzleState(), &mappedSwizzle);
// Renderable textures cannot have a swizzle.
ASSERT(!contextVk->getTextureCaps().get(format.internalFormat).textureAttachment ||
!mappedSwizzle.swizzleRequired());
// TODO(jmadill): Separate imageviews for RenderTargets and Sampling.
ANGLE_TRY(mImage.initImageView(device, mState.getType(), VK_IMAGE_ASPECT_COLOR_BIT,
mappedSwizzle, &mMipmapImageView, levelCount));
......
......@@ -175,7 +175,7 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const vk::ImageView &getImageView() const;
const vk::Sampler &getSampler() const;
vk::Error ensureImageInitialized(RendererVk *renderer);
vk::Error ensureImageInitialized(ContextVk *contextVk);
private:
void generateMipmapWithBlit(RendererVk *renderer);
......@@ -198,7 +198,7 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const gl::Rectangle &sourceArea,
const gl::InternalFormat &internalFormat,
gl::Framebuffer *source);
vk::Error initImage(RendererVk *renderer,
vk::Error initImage(ContextVk *contextVk,
const vk::Format &format,
const gl::Extents &extents,
const uint32_t levelCount,
......
......@@ -86,7 +86,8 @@ bool HasFullFormatSupport(VkPhysicalDevice physicalDevice, VkFormat vkFormat)
// Format implementation.
Format::Format()
: internalFormat(GL_NONE),
: angleFormatID(angle::Format::ID::NONE),
internalFormat(GL_NONE),
textureFormatID(angle::Format::ID::NONE),
vkTextureFormat(VK_FORMAT_UNDEFINED),
bufferFormatID(angle::Format::ID::NONE),
......@@ -106,6 +107,11 @@ const angle::Format &Format::bufferFormat() const
return angle::Format::Get(bufferFormatID);
}
const angle::Format &Format::angleFormat() const
{
return angle::Format::Get(angleFormatID);
}
bool operator==(const Format &lhs, const Format &rhs)
{
return &lhs == &rhs;
......@@ -137,6 +143,7 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice,
const GLenum internalFormat = mFormatData[formatIndex].internalFormat;
mFormatData[formatIndex].loadFunctions =
GetLoadFunctionsMap(internalFormat, mFormatData[formatIndex].textureFormatID);
mFormatData[formatIndex].angleFormatID = formatID;
if (!mFormatData[formatIndex].valid())
{
......
......@@ -43,7 +43,9 @@ struct Format final : private angle::NonCopyable
const angle::Format &textureFormat() const;
const angle::Format &bufferFormat() const;
const angle::Format &angleFormat() const;
angle::Format::ID angleFormatID;
GLenum internalFormat;
angle::Format::ID textureFormatID;
VkFormat vkTextureFormat;
......
......@@ -611,10 +611,20 @@ Error ImageHelper::initImageView(VkDevice device,
viewInfo.image = mImage.getHandle();
viewInfo.viewType = gl_vk::GetImageViewType(textureType);
viewInfo.format = mFormat->vkTextureFormat;
viewInfo.components.r = gl_vk::GetSwizzle(swizzleMap.swizzleRed);
viewInfo.components.g = gl_vk::GetSwizzle(swizzleMap.swizzleGreen);
viewInfo.components.b = gl_vk::GetSwizzle(swizzleMap.swizzleBlue);
viewInfo.components.a = gl_vk::GetSwizzle(swizzleMap.swizzleAlpha);
if (swizzleMap.swizzleRequired())
{
viewInfo.components.r = gl_vk::GetSwizzle(swizzleMap.swizzleRed);
viewInfo.components.g = gl_vk::GetSwizzle(swizzleMap.swizzleGreen);
viewInfo.components.b = gl_vk::GetSwizzle(swizzleMap.swizzleBlue);
viewInfo.components.a = gl_vk::GetSwizzle(swizzleMap.swizzleAlpha);
}
else
{
viewInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
}
viewInfo.subresourceRange.aspectMask = aspectMask;
viewInfo.subresourceRange.baseMipLevel = 0;
viewInfo.subresourceRange.levelCount = levelCount;
......
......@@ -201,6 +201,11 @@
2605 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.resize.rbo_rgba4_stencil_index8 = SKIP
2605 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.stencil.* = SKIP
2605 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.stencil_clear.* = SKIP
2597 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.color_clear.rbo_rgb565_stencil_index8 = SKIP
2597 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.color_clear.tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.color_clear.tex2d_rgba_stencil_index8 = SKIP
2597 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN ANDROID : dEQP-GLES2.functional.fbo.render.resize.tex2d_rgba_stencil_index8 = SKIP
2605 VULKAN ANDROID : dEQP-GLES2.functional.state_query.rbo.renderbuffer_component_size_depth = SKIP
2606 VULKAN ANDROID : dEQP-GLES2.functional.debug_marker.random = SKIP
2606 VULKAN ANDROID : dEQP-GLES2.functional.debug_marker.supported = SKIP
......@@ -220,34 +225,30 @@
2592 VULKAN : dEQP-GLES2.functional.shaders.builtin_variable.depth_range* = SKIP
2594 VULKAN : dEQP-GLES2.functional.shaders.fragdata.valid_static_index = SKIP
2595 VULKAN : dEQP-GLES2.functional.shaders.random.all_features.fragment* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color_clear.* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil_clear.tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color.* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.depth.tex2d_rgb_depth_component16 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color.blend_rbo_rgb5_a* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color.blend_npot_rbo_rgb5_a* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color_clear.tex2d_rgb_depth_component16_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color_clear.tex2d_rgba_depth_component16_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color_clear.rbo_rgb565_depth_component16_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.color_clear.rbo_rgb5_a1_depth_component16_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.depth.rbo_rgb5_a1_depth_component16 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.depth.npot_tex2d_rgb_depth_component16 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.depth.npot_rbo_rgb5_a1_depth_component16 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil.tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil_clear.tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil.rbo_rgb5_a1_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil.npot_tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil.npot_rbo_rgb5_a1_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.shared_colorbuffer_clear.tex2d_rgb = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.shared_colorbuffer_clear.rbo_rgb5_a1 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil.npot_tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.stencil.npot_tex2d_rgba_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.shared_colorbuffer.* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.shared_colorbuffer_clear.rbo_rgb5_a1 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.resize.rbo_rgb5_a* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgb = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_rbo_rgb5_a* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.no_rebind_rbo_rgb5_a* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_depthbuffer.rebind_tex2d_rgb_depth_component16 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_depthbuffer.rebind_rbo_rgb5_a1_* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_depthbuffer.no_rebind_tex2d_rgb_depth_component16 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_depthbuffer.no_rebind_rbo_rgb5_a1_* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.rebind_tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.rebind_rbo_rgb5_a1_* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.no_rebind_tex2d_rgb_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.no_rebind_rbo_rgb* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.no_rebind_rbo_rgb565_depth_component16_stencil_index8 = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.no_rebind_rbo_rgb5_a1* = SKIP
2597 VULKAN : dEQP-GLES2.functional.fbo.render.recreate_stencilbuffer.no_rebind_rbo_rgba4_depth_component16_stencil_index8 = SKIP
2161 VULKAN : dEQP-GLES2.functional.vertex_arrays.* = SKIP
2598 VULKAN : dEQP-GLES2.functional.rasterization.primitives.line* = SKIP
2599 VULKAN : dEQP-GLES2.functional.rasterization.limits.points = SKIP
......
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