本文整理汇总了C++中GrVkRenderTarget类的典型用法代码示例。如果您正苦于以下问题:C++ GrVkRenderTarget类的具体用法?C++ GrVkRenderTarget怎么用?C++ GrVkRenderTarget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GrVkRenderTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: discard
void GrVkGpuRTCommandBuffer::discard() {
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
if (cbInfo.fIsEmpty) {
// Change the render pass to do a don't-care load for both color & stencil
GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
VK_ATTACHMENT_STORE_OP_STORE);
GrVkRenderPass::LoadStoreOps vkStencilOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
VK_ATTACHMENT_STORE_OP_STORE);
const GrVkRenderPass* oldRP = cbInfo.fRenderPass;
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
SkASSERT(cbInfo.fRenderPass->isCompatible(*oldRP));
oldRP->unref(fGpu);
cbInfo.fBounds.join(fRenderTarget->getBoundsRect());
cbInfo.fLoadStoreState = LoadStoreState::kStartsWithDiscard;
}
}
示例2: vkColorOps
void GrVkGpuCommandBuffer::discard(GrRenderTarget* target) {
if (fIsEmpty) {
// We will change the render pass to do a clear load instead
GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
VK_ATTACHMENT_STORE_OP_STORE);
GrVkRenderPass::LoadStoreOps vkStencilOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
VK_ATTACHMENT_STORE_OP_STORE);
const GrVkRenderPass* oldRP = fRenderPass;
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(target);
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
SkASSERT(fRenderPass->isCompatible(*oldRP));
oldRP->unref(fGpu);
fStartsWithClear = false;
}
}
示例3: b
void GrVkPipelineState::BuildStateKey(const GrPipeline& pipeline, GrPrimitiveType primitiveType,
SkTArray<uint8_t, true>* key) {
// Save room for the key length and key header
key->reset();
key->push_back_n(kData_StateKeyOffset);
GrProcessorKeyBuilder b(key);
GrVkRenderTarget* vkRT = (GrVkRenderTarget*)pipeline.getRenderTarget();
vkRT->simpleRenderPass()->genKey(&b);
pipeline.getStencil().genKey(&b);
SkASSERT(sizeof(GrPipelineBuilder::DrawFace) <= sizeof(uint32_t));
b.add32(pipeline.getDrawFace());
b.add32(get_blend_info_key(pipeline));
b.add32(primitiveType);
// Set key length
int keyLength = key->count();
SkASSERT(0 == (keyLength % 4));
*reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength);
}
示例4: addAdditionalRenderPass
void GrVkGpuRTCommandBuffer::addAdditionalRenderPass() {
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
fCommandBufferInfos[fCurrentCmdInfo].currentCmdBuf()->end(fGpu);
CommandBufferInfo& cbInfo = fCommandBufferInfos.push_back();
fCurrentCmdInfo++;
GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_LOAD,
VK_ATTACHMENT_STORE_OP_STORE);
GrVkRenderPass::LoadStoreOps vkStencilOps(VK_ATTACHMENT_LOAD_OP_LOAD,
VK_ATTACHMENT_STORE_OP_STORE);
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
cbInfo.fLoadStoreState = LoadStoreState::kLoadAndStore;
cbInfo.fCommandBuffers.push_back(fGpu->cmdPool()->findOrCreateSecondaryCommandBuffer(fGpu));
// It shouldn't matter what we set the clear color to here since we will assume loading of the
// attachment.
memset(&cbInfo.fColorClearValue, 0, sizeof(VkClearValue));
cbInfo.fBounds.setEmpty();
cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
}
示例5: beginRenderPass
void GrVkPrimaryCommandBuffer::beginRenderPass(const GrVkGpu* gpu,
const GrVkRenderPass* renderPass,
uint32_t clearCount,
const VkClearValue* clearValues,
const GrVkRenderTarget& target,
const SkIRect& bounds,
bool forSecondaryCB) {
SkASSERT(fIsActive);
SkASSERT(!fActiveRenderPass);
SkASSERT(renderPass->isCompatible(target));
VkRenderPassBeginInfo beginInfo;
VkRect2D renderArea;
renderArea.offset = { bounds.fLeft , bounds.fTop };
renderArea.extent = { (uint32_t)bounds.width(), (uint32_t)bounds.height() };
memset(&beginInfo, 0, sizeof(VkRenderPassBeginInfo));
beginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
beginInfo.pNext = nullptr;
beginInfo.renderPass = renderPass->vkRenderPass();
beginInfo.framebuffer = target.framebuffer()->framebuffer();
beginInfo.renderArea = renderArea;
beginInfo.clearValueCount = clearCount;
beginInfo.pClearValues = clearValues;
VkSubpassContents contents = forSecondaryCB ? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
: VK_SUBPASS_CONTENTS_INLINE;
GR_VK_CALL(gpu->vkInterface(), CmdBeginRenderPass(fCmdBuffer, &beginInfo, contents));
fActiveRenderPass = renderPass;
this->addResource(renderPass);
target.addResources(*this);
}
示例6: addAdditionalCommandBuffer
void GrVkGpuRTCommandBuffer::addAdditionalCommandBuffer() {
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
cbInfo.currentCmdBuf()->end(fGpu);
cbInfo.fCommandBuffers.push_back(fGpu->cmdPool()->findOrCreateSecondaryCommandBuffer(fGpu));
cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
}
示例7: SkASSERT
void GrVkGpuRTCommandBuffer::initWrapped() {
CommandBufferInfo& cbInfo = fCommandBufferInfos.push_back();
SkASSERT(fCommandBufferInfos.count() == 1);
fCurrentCmdInfo = 0;
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
SkASSERT(vkRT->wrapsSecondaryCommandBuffer());
cbInfo.fRenderPass = vkRT->externalRenderPass();
cbInfo.fRenderPass->ref();
cbInfo.fBounds.setEmpty();
cbInfo.fCommandBuffers.push_back(vkRT->getExternalSecondaryCommandBuffer());
cbInfo.fCommandBuffers[0]->ref();
cbInfo.currentCmdBuf()->begin(fGpu, nullptr, cbInfo.fRenderPass);
}
示例8: isCompatible
bool GrVkRenderPass::isCompatible(const GrVkRenderTarget& target) const {
AttachmentsDescriptor desc;
AttachmentFlags flags;
target.getAttachmentsDescriptor(&desc, &flags);
return this->isCompatible(desc, flags);
}
示例9: init
void GrVkRenderPass::init(const GrVkGpu* gpu,
const GrVkRenderTarget& target,
const LoadStoreOps& colorOp,
const LoadStoreOps& resolveOp,
const LoadStoreOps& stencilOp) {
// Get attachment information from render target. This includes which attachments the render
// target has (color, resolve, stencil) and the attachments format and sample count.
target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags);
this->init(gpu, colorOp, resolveOp, stencilOp);
}
示例10: vkColorOps
void GrVkGpuRTCommandBuffer::init() {
GrVkRenderPass::LoadStoreOps vkColorOps(fVkColorLoadOp, fVkColorStoreOp);
GrVkRenderPass::LoadStoreOps vkStencilOps(fVkStencilLoadOp, fVkStencilStoreOp);
CommandBufferInfo& cbInfo = fCommandBufferInfos.push_back();
SkASSERT(fCommandBufferInfos.count() == 1);
fCurrentCmdInfo = 0;
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
const GrVkResourceProvider::CompatibleRPHandle& rpHandle = vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
cbInfo.fColorClearValue.color.float32[0] = fClearColor[0];
cbInfo.fColorClearValue.color.float32[1] = fClearColor[1];
cbInfo.fColorClearValue.color.float32[2] = fClearColor[2];
cbInfo.fColorClearValue.color.float32[3] = fClearColor[3];
if (VK_ATTACHMENT_LOAD_OP_CLEAR == fVkColorLoadOp) {
cbInfo.fBounds = SkRect::MakeWH(vkRT->width(), vkRT->height());
} else {
cbInfo.fBounds.setEmpty();
}
if (VK_ATTACHMENT_LOAD_OP_CLEAR == fVkColorLoadOp) {
cbInfo.fLoadStoreState = LoadStoreState::kStartsWithClear;
} else if (VK_ATTACHMENT_LOAD_OP_LOAD == fVkColorLoadOp &&
VK_ATTACHMENT_STORE_OP_STORE == fVkColorStoreOp) {
cbInfo.fLoadStoreState = LoadStoreState::kLoadAndStore;
} else if (VK_ATTACHMENT_LOAD_OP_DONT_CARE == fVkColorLoadOp) {
cbInfo.fLoadStoreState = LoadStoreState::kStartsWithDiscard;
}
cbInfo.fCommandBuffers.push_back(fGpu->cmdPool()->findOrCreateSecondaryCommandBuffer(fGpu));
cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
}
示例11: 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));
}
}
示例12: getBeginInfo
void GrVkRenderPass::getBeginInfo(const GrVkRenderTarget& target,
VkRenderPassBeginInfo* beginInfo,
VkSubpassContents* contents) const {
SkASSERT(this->isCompatible(target));
VkRect2D renderArea;
renderArea.offset = { 0, 0 };
renderArea.extent = { (uint32_t)target.width(), (uint32_t)target.height() };
memset(beginInfo, 0, sizeof(VkRenderPassBeginInfo));
beginInfo->sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
beginInfo->pNext = nullptr;
beginInfo->renderPass = fRenderPass;
beginInfo->framebuffer = target.framebuffer()->framebuffer();
beginInfo->renderArea = renderArea;
beginInfo->clearValueCount = 0;
beginInfo->pClearValues = nullptr;
// Currently just assuming no secondary cmd buffers. This value will need to be update if we
// have them.
*contents = VK_SUBPASS_CONTENTS_INLINE;
}
示例13: beginRenderPass
void GrVkCommandBuffer::beginRenderPass(const GrVkGpu* gpu,
const GrVkRenderPass* renderPass,
const GrVkRenderTarget& target) {
SkASSERT(fIsActive);
SkASSERT(!fActiveRenderPass);
VkRenderPassBeginInfo beginInfo;
VkSubpassContents contents;
renderPass->getBeginInfo(target, &beginInfo, &contents);
GR_VK_CALL(gpu->vkInterface(), CmdBeginRenderPass(fCmdBuffer, &beginInfo, contents));
fActiveRenderPass = renderPass;
this->addResource(renderPass);
target.addResources(*this);
}
示例14: SkASSERT
void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTarget* target,
const GrFixedClip& clip,
bool insideStencilMask) {
SkASSERT(target);
SkASSERT(!clip.hasWindowRectangles());
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(target);
GrStencilAttachment* sb = target->renderTargetPriv().getStencilAttachment();
// this should only be called internally when we know we have a
// stencil buffer.
SkASSERT(sb);
int stencilBitCount = sb->bits();
// The contract with the callers does not guarantee that we preserve all bits in the stencil
// during this clear. Thus we will clear the entire stencil to the desired value.
VkClearDepthStencilValue vkStencilColor;
memset(&vkStencilColor, 0, sizeof(VkClearDepthStencilValue));
if (insideStencilMask) {
vkStencilColor.stencil = (1 << (stencilBitCount - 1));
} else {
vkStencilColor.stencil = 0;
}
VkClearRect clearRect;
// Flip rect if necessary
SkIRect vkRect;
if (!clip.scissorEnabled()) {
vkRect.setXYWH(0, 0, vkRT->width(), vkRT->height());
} else if (kBottomLeft_GrSurfaceOrigin != vkRT->origin()) {
vkRect = clip.scissorRect();
} else {
const SkIRect& scissor = clip.scissorRect();
vkRect.setLTRB(scissor.fLeft, vkRT->height() - scissor.fBottom,
scissor.fRight, vkRT->height() - scissor.fTop);
}
clearRect.rect.offset = { vkRect.fLeft, vkRect.fTop };
clearRect.rect.extent = { (uint32_t)vkRect.width(), (uint32_t)vkRect.height() };
clearRect.baseArrayLayer = 0;
clearRect.layerCount = 1;
uint32_t stencilIndex;
SkAssertResult(fRenderPass->stencilAttachmentIndex(&stencilIndex));
VkClearAttachment attachment;
attachment.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT;
attachment.colorAttachment = 0; // this value shouldn't matter
attachment.clearValue.depthStencil = vkStencilColor;
fCommandBuffer->clearAttachments(fGpu, 1, &attachment, 1, &clearRect);
fIsEmpty = false;
}
示例15: onClear
void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, const SkPMColor4f& color) {
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
// parent class should never let us get here with no RT
SkASSERT(!clip.hasWindowRectangles());
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
VkClearColorValue vkColor = {{color.fR, color.fG, color.fB, color.fA}};
if (cbInfo.fIsEmpty && !clip.scissorEnabled()) {
// Change the render pass to do a clear load
GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_CLEAR,
VK_ATTACHMENT_STORE_OP_STORE);
// Preserve the stencil buffer's load & store settings
GrVkRenderPass::LoadStoreOps vkStencilOps(fVkStencilLoadOp, fVkStencilStoreOp);
const GrVkRenderPass* oldRP = cbInfo.fRenderPass;
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
SkASSERT(cbInfo.fRenderPass->isCompatible(*oldRP));
oldRP->unref(fGpu);
cbInfo.fColorClearValue.color = {{color.fR, color.fG, color.fB, color.fA}};
cbInfo.fLoadStoreState = LoadStoreState::kStartsWithClear;
// Update command buffer bounds
cbInfo.fBounds.join(fRenderTarget->getBoundsRect());
return;
}
// We always do a sub rect clear with clearAttachments since we are inside a render pass
VkClearRect clearRect;
// Flip rect if necessary
SkIRect vkRect;
if (!clip.scissorEnabled()) {
vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height());
} else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
vkRect = clip.scissorRect();
} else {
const SkIRect& scissor = clip.scissorRect();
vkRect.setLTRB(scissor.fLeft, fRenderTarget->height() - scissor.fBottom,
scissor.fRight, fRenderTarget->height() - scissor.fTop);
}
clearRect.rect.offset = { vkRect.fLeft, vkRect.fTop };
clearRect.rect.extent = { (uint32_t)vkRect.width(), (uint32_t)vkRect.height() };
clearRect.baseArrayLayer = 0;
clearRect.layerCount = 1;
uint32_t colorIndex;
SkAssertResult(cbInfo.fRenderPass->colorAttachmentIndex(&colorIndex));
VkClearAttachment attachment;
attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
attachment.colorAttachment = colorIndex;
attachment.clearValue.color = vkColor;
cbInfo.currentCmdBuf()->clearAttachments(fGpu, 1, &attachment, 1, &clearRect);
cbInfo.fIsEmpty = false;
// Update command buffer bounds
if (!clip.scissorEnabled()) {
cbInfo.fBounds.join(fRenderTarget->getBoundsRect());
} else {
cbInfo.fBounds.join(SkRect::Make(clip.scissorRect()));
}
return;
}