MCPcopy Create free account
hub / github.com/cocos/cocos-engine / begin

Method begin

native/cocos/renderer/frame-graph/DevicePass.cpp:326–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326void DevicePass::begin(gfx::CommandBuffer *cmdBuff) {
327 if (_attachments.empty()) return;
328
329 gfx::RenderPassInfo rpInfo;
330 gfx::FramebufferInfo fboInfo;
331 float clearDepth = 1.F;
332 uint32_t clearStencil = 0;
333 static ccstd::vector<gfx::Color> clearColors;
334 clearColors.clear();
335
336 bool hasDefaultViewport{false};
337 for (auto &subpass : _subpasses) {
338 for (auto &pass : subpass.logicPasses) {
339 if (!pass.customViewport) {
340 hasDefaultViewport = true;
341 break;
342 }
343 }
344 }
345
346 if (hasDefaultViewport) {
347 _viewport = {};
348 _scissor = {0, 0, UINT_MAX, UINT_MAX};
349 } else { // if all passes use customize viewport
350 _scissor = {INT_MAX, INT_MAX, 0, 0};
351
352 for (auto &subpass : _subpasses) {
353 for (auto &pass : subpass.logicPasses) {
354 // calculate the union of all viewports as render area
355 _viewport.left = _scissor.x = std::min(_scissor.x, pass.viewport.left);
356 _viewport.top = _scissor.y = std::min(_scissor.y, pass.viewport.top);
357 _viewport.width = _scissor.width = std::max(_scissor.width, pass.viewport.width + pass.viewport.left - _scissor.x);
358 _viewport.height = _scissor.height = std::max(_scissor.height, pass.viewport.height + pass.viewport.top - _scissor.y);
359 }
360 }
361 }
362
363 for (const auto &attachElem : _attachments) {
364 gfx::Texture *attachment = attachElem.renderTarget;
365 if (attachElem.attachment.desc.usage == RenderTargetAttachment::Usage::COLOR) {
366 rpInfo.colorAttachments.emplace_back();
367 auto &attachmentInfo = rpInfo.colorAttachments.back();
368 attachmentInfo.format = attachment->getFormat();
369 attachmentInfo.loadOp = attachElem.attachment.desc.loadOp;
370 attachmentInfo.storeOp = attachElem.attachment.storeOp;
371 attachmentInfo.barrier = gfx::Device::getInstance()->getGeneralBarrier({attachElem.attachment.desc.beginAccesses, attachElem.attachment.desc.endAccesses});
372 fboInfo.colorTextures.push_back(attachElem.renderTarget);
373 clearColors.emplace_back(attachElem.attachment.desc.clearColor);
374 } else {
375 auto &attachmentInfo = rpInfo.depthStencilAttachment;
376 attachmentInfo.format = attachment->getFormat();
377 attachmentInfo.depthLoadOp = attachElem.attachment.desc.loadOp;
378 attachmentInfo.stencilLoadOp = attachElem.attachment.desc.loadOp;
379 attachmentInfo.depthStoreOp = attachElem.attachment.storeOp;
380 attachmentInfo.stencilStoreOp = attachElem.attachment.storeOp;
381 attachmentInfo.barrier = gfx::Device::getInstance()->getGeneralBarrier({attachElem.attachment.desc.beginAccesses, attachElem.attachment.desc.endAccesses});
382 fboInfo.depthStencilTexture = attachElem.renderTarget;
383 clearDepth = attachElem.attachment.desc.clearDepth;

Callers 15

freeMethod · 0.45
findAvailableSpaceMethod · 0.45
populateMacrosFunction · 0.45
insertBuiltinBindingsFunction · 0.45
presentLastVersionMethod · 0.45
hasPassMethod · 0.45
sortMethod · 0.45
getResourceNodeMethod · 0.45
DevicePassMethod · 0.45
appendMethod · 0.45
readMethod · 0.45

Calls 15

getFormatMethod · 0.80
createTransientMethod · 0.80
clearMethod · 0.65
push_backMethod · 0.65
getMethod · 0.65
beginRenderPassMethod · 0.65
setViewportMethod · 0.65
minFunction · 0.50
maxFunction · 0.50
RenderPassClass · 0.50
FramebufferClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected