本文整理汇总了C++中GrVkRenderTarget::msaaImage方法的典型用法代码示例。如果您正苦于以下问题:C++ GrVkRenderTarget::msaaImage方法的具体用法?C++ GrVkRenderTarget::msaaImage怎么用?C++ GrVkRenderTarget::msaaImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrVkRenderTarget
的用法示例。
在下文中一共展示了GrVkRenderTarget::msaaImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeDrawable
void GrVkGpuRTCommandBuffer::executeDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable) {
GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(fRenderTarget);
GrVkImage* targetImage = target->msaaImage() ? target->msaaImage() : target;
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
VkRect2D bounds;
bounds.offset = { 0, 0 };
bounds.extent = { 0, 0 };
GrVkDrawableInfo vkInfo;
vkInfo.fSecondaryCommandBuffer = cbInfo.currentCmdBuf()->vkCommandBuffer();
vkInfo.fCompatibleRenderPass = cbInfo.fRenderPass->vkRenderPass();
SkAssertResult(cbInfo.fRenderPass->colorAttachmentIndex(&vkInfo.fColorAttachmentIndex));
vkInfo.fFormat = targetImage->imageFormat();
vkInfo.fDrawBounds = &bounds;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
vkInfo.fImage = targetImage->image();
#else
vkInfo.fImage = VK_NULL_HANDLE;
#endif //SK_BUILD_FOR_ANDROID_FRAMEWORK
GrBackendDrawableInfo info(vkInfo);
// After we draw into the command buffer via the drawable, cached state we have may be invalid.
cbInfo.currentCmdBuf()->invalidateState();
// Also assume that the drawable produced output.
cbInfo.fIsEmpty = false;
drawable->draw(info);
fGpu->addDrawable(std::move(drawable));
if (bounds.extent.width == 0 || bounds.extent.height == 0) {
cbInfo.fBounds.join(target->getBoundsRect());
} else {
cbInfo.fBounds.join(SkRect::MakeXYWH(bounds.offset.x, bounds.offset.y,
bounds.extent.width, bounds.extent.height));
}
}
示例2: submit
void GrVkGpuRTCommandBuffer::submit() {
if (!fRenderTarget) {
return;
}
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
GrVkImage* targetImage = vkRT->msaaImage() ? vkRT->msaaImage() : vkRT;
GrStencilAttachment* stencil = fRenderTarget->renderTargetPriv().getStencilAttachment();
auto currPreCmd = fPreCommandBufferTasks.begin();
GrVkPrimaryCommandBufferTask::Args taskArgs{fGpu, fRenderTarget, fOrigin};
for (int i = 0; i < fCommandBufferInfos.count(); ++i) {
CommandBufferInfo& cbInfo = fCommandBufferInfos[i];
for (int c = 0; c < cbInfo.fNumPreCmds; ++c, ++currPreCmd) {
currPreCmd->execute(taskArgs);
}
// TODO: Many things create a scratch texture which adds the discard immediately, but then
// don't draw to it right away. This causes the discard to be ignored and we get yelled at
// for loading uninitialized data. However, once MDB lands with reordering, the discard will
// get reordered with the rest of the draw commands and we can remove the discard check.
if (cbInfo.fIsEmpty &&
cbInfo.fLoadStoreState != LoadStoreState::kStartsWithClear &&
cbInfo.fLoadStoreState != LoadStoreState::kStartsWithDiscard) {
// We have sumbitted no actual draw commands to the command buffer and we are not using
// the render pass to do a clear so there is no need to submit anything.
continue;
}
// We don't want to actually submit the secondary command buffer if it is wrapped.
if (this->wrapsSecondaryCommandBuffer()) {
// If we have any sampled images set their layout now.
for (int j = 0; j < cbInfo.fSampledTextures.count(); ++j) {
cbInfo.fSampledTextures[j]->setImageLayout(
fGpu, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, false);
}
// There should have only been one secondary command buffer in the wrapped case so it is
// safe to just return here.
SkASSERT(fCommandBufferInfos.count() == 1);
return;
}
// Make sure if we only have a discard load that we execute the discard on the whole image.
// TODO: Once we improve our tracking of discards so that we never end up flushing a discard
// call with no actually ops, remove this.
if (cbInfo.fIsEmpty && cbInfo.fLoadStoreState == LoadStoreState::kStartsWithDiscard) {
cbInfo.fBounds = SkRect::MakeWH(vkRT->width(), vkRT->height());
}
if (cbInfo.fBounds.intersect(0, 0,
SkIntToScalar(fRenderTarget->width()),
SkIntToScalar(fRenderTarget->height()))) {
// Make sure we do the following layout changes after all copies, uploads, or any other
// pre-work is done since we may change the layouts in the pre-work. Also since the
// draws will be submitted in different render passes, we need to guard againts write
// and write issues.
// Change layout of our render target so it can be used as the color attachment.
// TODO: If we know that we will never be blending or loading the attachment we could
// drop the VK_ACCESS_COLOR_ATTACHMENT_READ_BIT.
targetImage->setImageLayout(fGpu,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
false);
// If we are using a stencil attachment we also need to update its layout
if (stencil) {
GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil;
// We need the write and read access bits since we may load and store the stencil.
// The initial load happens in the VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT so we
// wait there.
vkStencil->setImageLayout(fGpu,
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
false);
}
// If we have any sampled images set their layout now.
for (int j = 0; j < cbInfo.fSampledTextures.count(); ++j) {
cbInfo.fSampledTextures[j]->setImageLayout(
fGpu, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, false);
}
SkIRect iBounds;
cbInfo.fBounds.roundOut(&iBounds);
fGpu->submitSecondaryCommandBuffer(cbInfo.fCommandBuffers, cbInfo.fRenderPass,
&cbInfo.fColorClearValue, vkRT, fOrigin, iBounds);
}
}
SkASSERT(currPreCmd == fPreCommandBufferTasks.end());
}
示例3: copySurfaceAsDraw
//.........这里部分代码省略.........
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkWriteDescriptorSet writeInfo;
memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet));
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = samplerDS->descriptorSet();
writeInfo.dstBinding = 0;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeInfo.pImageInfo = &imageInfo;
writeInfo.pBufferInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(),
1,
&writeInfo,
0, nullptr));
VkDescriptorSet vkDescSets[] = { uniformDS->descriptorSet(), samplerDS->descriptorSet() };
GrVkRenderTarget* texRT = static_cast<GrVkRenderTarget*>(srcTex->asRenderTarget());
if (texRT) {
gpu->resolveRenderTargetNoFlush(texRT);
}
// TODO: Make tighter bounds and then adjust bounds for origin and granularity if we see
// any perf issues with using the whole bounds
SkIRect bounds = SkIRect::MakeWH(rt->width(), rt->height());
// Change layouts of rt and texture. We aren't blending so we don't need color attachment read
// access for blending.
GrVkImage* targetImage = rt->msaaImage() ? rt->msaaImage() : rt;
VkAccessFlags dstAccessFlags = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
if (!canDiscardOutsideDstRect) {
// We need to load the color attachment so need to be able to read it.
dstAccessFlags |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
}
targetImage->setImageLayout(gpu,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
dstAccessFlags,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
false);
srcTex->setImageLayout(gpu,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
VK_ACCESS_SHADER_READ_BIT,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
false);
GrStencilAttachment* stencil = rt->renderTargetPriv().getStencilAttachment();
if (stencil) {
GrVkStencilAttachment* vkStencil = (GrVkStencilAttachment*)stencil;
// We aren't actually using the stencil but we still load and store it so we need
// appropriate barriers.
// TODO: Once we refactor surface and how we conntect stencil to RTs, we should not even
// have the stencil on this render pass if possible.
vkStencil->setImageLayout(gpu,
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
false);
}