Hash :
20fa8d5c
Author :
Date :
2018-04-15T10:09:32
Vulkan: Implement cube map texture sampling. This changes the TextureVk class to have a queue of staging copies, instead of a single copy at a time. This will allow us to upload multiple sub regions of a texture image at once when we need to resolve the Image at sampling time. Enables the remainder of the texture.format tests, and all non-mipped tests in the texture.size tests. Also updates the expectations with the bug number for mipmap support. Bug: angleproject:2318 Change-Id: Ie55f8f2dc24d7b133ad735e37f0f78937f022b5b Reviewed-on: https://chromium-review.googlesource.com/980775 Reviewed-by: Luc Ferron <lucferron@chromium.org> Commit-Queue: Jamie Madill <jmadill@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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
//
// Copyright 2016 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.
//
// RenderbufferVk.cpp:
// Implements the class methods for RenderbufferVk.
//
#include "libANGLE/renderer/vulkan/RenderbufferVk.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
namespace rx
{
namespace
{
constexpr VkClearDepthStencilValue kDefaultClearDepthStencilValue = {0.0f, 1};
constexpr VkClearColorValue kBlackClearColorValue = {{0}};
} // anonymous namespace
RenderbufferVk::RenderbufferVk(const gl::RenderbufferState &state) : RenderbufferImpl(state)
{
mRenderTarget.image = &mImage;
mRenderTarget.imageView = &mImageView;
mRenderTarget.resource = this;
}
RenderbufferVk::~RenderbufferVk()
{
}
gl::Error RenderbufferVk::onDestroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
mImage.release(renderer->getCurrentQueueSerial(), renderer);
renderer->releaseResource(*this, &mImageView);
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
return gl::NoError();
}
gl::Error RenderbufferVk::setStorage(const gl::Context *context,
GLenum internalformat,
size_t width,
size_t height)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
const vk::Format &vkFormat = renderer->getFormat(internalformat);
VkDevice device = renderer->getDevice();
if (mImage.valid())
{
// Check against the state if we need to recreate the storage.
if (internalformat != mState.getFormat().info->internalFormat ||
static_cast<GLsizei>(width) != mState.getWidth() ||
static_cast<GLsizei>(height) != mState.getHeight())
{
mImage.release(renderer->getCurrentQueueSerial(), renderer);
renderer->releaseResource(*this, &mImageView);
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
}
}
if (!mImage.valid() && (width != 0 || height != 0))
{
const angle::Format &textureFormat = vkFormat.textureFormat();
bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0;
const VkImageUsageFlags usage =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT |
(textureFormat.redBits > 0 ? VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT : 0) |
(isDepthOrStencilFormat ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : 0);
gl::Extents extents(static_cast<int>(width), static_cast<int>(height), 1);
ANGLE_TRY(mImage.init(device, gl::TextureType::_2D, extents, vkFormat, 1, usage));
VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
ANGLE_TRY(mImage.initMemory(device, renderer->getMemoryProperties(), flags));
VkImageAspectFlags aspect =
(textureFormat.depthBits > 0 ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) |
(textureFormat.stencilBits > 0 ? VK_IMAGE_ASPECT_STENCIL_BIT : 0) |
(textureFormat.redBits > 0 ? VK_IMAGE_ASPECT_COLOR_BIT : 0);
ANGLE_TRY(mImage.initImageView(device, gl::TextureType::_2D, aspect, gl::SwizzleState(),
&mImageView));
// TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(beginWriteResource(renderer, &commandBuffer));
if (isDepthOrStencilFormat)
{
mImage.clearDepthStencil(aspect, kDefaultClearDepthStencilValue, commandBuffer);
}
else
{
mImage.clearColor(kBlackClearColorValue, commandBuffer);
}
}
return gl::NoError();
}
gl::Error RenderbufferVk::setStorageMultisample(const gl::Context *context,
size_t samples,
GLenum internalformat,
size_t width,
size_t height)
{
UNIMPLEMENTED();
return gl::InternalError();
}
gl::Error RenderbufferVk::setStorageEGLImageTarget(const gl::Context *context, egl::Image *image)
{
UNIMPLEMENTED();
return gl::InternalError();
}
gl::Error RenderbufferVk::getAttachmentRenderTarget(const gl::Context * /*context*/,
GLenum /*binding*/,
const gl::ImageIndex & /*imageIndex*/,
FramebufferAttachmentRenderTarget **rtOut)
{
ASSERT(mImage.valid());
*rtOut = &mRenderTarget;
return gl::NoError();
}
gl::Error RenderbufferVk::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
UNIMPLEMENTED();
return gl::NoError();
}
} // namespace rx