Hash :
316c6065
Author :
Date :
2018-05-29T10:49:45
Vulkan: Call GraphResource instead of GraphNode. We don't need to use the CommandGraphNode class directly. This CL consolidates our code so we never call the GraphNodes class directly. Instead we call operations on GraphResource. This should simplify the interaction with APIs from the various graph and dependency management classes in the Vulkan back-end. A new concept of 'starting' vs 'appending' commands is introduced. Appending tries to avoid starting new command buffers when possible. Should not change how the graphs are constructed, and mostly be a refactoring change. There may be minor behaviour changes to some commands. Bug: angleproject:2539 Change-Id: Ia971e5cacb1164b9b3b22fa4a0a55b954d81f10e Reviewed-on: https://chromium-review.googlesource.com/1052068 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@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
//
// 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.
//
// RenderTargetVk:
// Wrapper around a Vulkan renderable resource, using an ImageView.
//
#include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
namespace rx
{
RenderTargetVk::RenderTargetVk(vk::ImageHelper *image,
vk::ImageView *imageView,
vk::CommandGraphResource *resource)
: mImage(image), mImageView(imageView), mResource(resource)
{
}
RenderTargetVk::~RenderTargetVk()
{
}
void RenderTargetVk::onColorDraw(vk::CommandGraphResource *framebufferVk,
vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
ASSERT(!mImage->getFormat().textureFormat().hasDepthOrStencilBits());
// Store the attachment info in the renderPassDesc.
renderPassDesc->packColorAttachment(*mImage);
// TODO(jmadill): Use automatic layout transition. http://anglebug.com/2361
mImage->changeLayoutWithStages(VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, commandBuffer);
// Set up dependencies between the RT resource and the Framebuffer.
mResource->addWriteDependency(framebufferVk);
}
void RenderTargetVk::onDepthStencilDraw(vk::CommandGraphResource *framebufferVk,
vk::CommandBuffer *commandBuffer,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
ASSERT(mImage->getFormat().textureFormat().hasDepthOrStencilBits());
// Store the attachment info in the renderPassDesc.
renderPassDesc->packDepthStencilAttachment(*mImage);
// TODO(jmadill): Use automatic layout transition. http://anglebug.com/2361
const angle::Format &format = mImage->getFormat().textureFormat();
VkImageAspectFlags aspectFlags = (format.depthBits > 0 ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) |
(format.stencilBits > 0 ? VK_IMAGE_ASPECT_STENCIL_BIT : 0);
mImage->changeLayoutWithStages(aspectFlags, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, commandBuffer);
// Set up dependencies between the RT resource and the Framebuffer.
mResource->addWriteDependency(framebufferVk);
}
const vk::ImageHelper &RenderTargetVk::getImage() const
{
ASSERT(mImage && mImage->valid());
return *mImage;
}
vk::ImageView *RenderTargetVk::getImageView() const
{
ASSERT(mImageView && mImageView->valid());
return mImageView;
}
vk::CommandGraphResource *RenderTargetVk::getResource() const
{
return mResource;
}
const vk::Format &RenderTargetVk::getImageFormat() const
{
ASSERT(mImage && mImage->valid());
return mImage->getFormat();
}
const gl::Extents &RenderTargetVk::getImageExtents() const
{
ASSERT(mImage && mImage->valid());
return mImage->getExtents();
}
void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageView *imageView)
{
ASSERT(image && image->valid() && imageView && imageView->valid());
mImage = image;
mImageView = imageView;
}
vk::ImageHelper *RenderTargetVk::getImageForWrite(Serial currentSerial,
vk::CommandGraphResource *writingResource) const
{
ASSERT(mImage && mImage->valid());
mResource->addWriteDependency(writingResource);
return mImage;
}
} // namespace rx