Skip to content

Commit

Permalink
fix Native Pipeline with render texture.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesky013 committed Jul 21, 2023
1 parent 72db332 commit 7bb959e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
13 changes: 10 additions & 3 deletions native/cocos/core/assets/EffectAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,16 @@ void EffectAsset::precompile() {
continue;
}

ccstd::vector<MacroRecord> defines = EffectAsset::doCombine(ccstd::vector<MacroRecord>(), combination, combination.begin());
for (auto &define : defines) {
ProgramLib::getInstance()->getGFXShader(root->getDevice(), shader.name, define, root->getPipeline());
// Native Program Lib can not precompile shader variant without phaseID.
// Shaders are compiled only during the compilation of PSO. A new mechanism may be needed for pre-compilation.
auto *programLib = render::getProgramLibrary();
if (programLib == nullptr) {
ccstd::vector<MacroRecord> defines = EffectAsset::doCombine(
ccstd::vector<MacroRecord>(), combination, combination.begin());
for (auto &define: defines) {
ProgramLib::getInstance()->getGFXShader(root->getDevice(), shader.name, define,
root->getPipeline());
}
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions native/cocos/renderer/gfx-gles3/GLES3Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,12 @@ void cmdFuncGLES3CreateFramebuffer(GLES3Device *device, GLES3GPUFramebuffer *gpu
if (lazilyAllocated && // MS attachment should be memoryless
resolveView->gpuTexture->swapchain == nullptr && // not back buffer
i < supportCount) { // extension limit
gpuFBO->framebuffer.bindColorMultiSample(resolveView, colorIndex, view->gpuTexture->glSamples, resolveDesc);
auto validateDesc = resolveDesc;
// implicit MS take color slot, so color loadOP should be used.
// resolve attachment with Store::Discard is meaningless.
validateDesc.loadOp = desc.loadOp;
validateDesc.storeOp = StoreOp::STORE;
gpuFBO->framebuffer.bindColorMultiSample(resolveView, colorIndex, view->gpuTexture->glSamples, validateDesc);
} else {
// implicit MS not supported, fallback to MS Renderbuffer
gpuFBO->colorBlitPairs.emplace_back(colorIndex, resolveColorIndex);
Expand All @@ -1609,7 +1614,14 @@ void cmdFuncGLES3CreateFramebuffer(GLES3Device *device, GLES3GPUFramebuffer *gpu
resolveView->gpuTexture->swapchain == nullptr && // not back buffer
supportCount > 1 && // extension limit
useDsResolve) { // enable ds resolve
gpuFBO->framebuffer.bindDepthStencilMultiSample(resolveView, view->gpuTexture->glSamples, resolveDesc);
auto validateDesc = resolveDesc;
// implicit MS take ds slot, so ds MS loadOP should be used.
// resolve attachment with Store::Discard is meaningless.
validateDesc.depthLoadOp = desc.depthLoadOp;
validateDesc.depthStoreOp = StoreOp::STORE;
validateDesc.stencilLoadOp = desc.stencilLoadOp;
validateDesc.stencilStoreOp = StoreOp::STORE;
gpuFBO->framebuffer.bindDepthStencilMultiSample(resolveView, view->gpuTexture->glSamples, validateDesc);
} else {
// implicit MS not supported, fallback to MS Renderbuffer
gpuFBO->dsResolveMask = getColorBufferMask(desc.format);
Expand Down
3 changes: 2 additions & 1 deletion native/cocos/renderer/pipeline/custom/NativeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ PersistentRenderPassAndFramebuffer createPersistentRenderPassAndFramebuffer(
[&](const IntrusivePtr<gfx::Framebuffer>& fb) {
CC_EXPECTS(fb->getColorTextures().size() == 1);
CC_EXPECTS(fb->getColorTextures().at(0));
fbInfo.colorTextures.emplace_back(fb->getColorTextures()[index]);
// usually gfx::Framebuffer comes form RenderWindow, and use as color or resolve attachment.
fbInfo.colorTextures.emplace_back(fb->getColorTextures()[0]);
// render window attaches a depthStencil by default, which may differs from renderpassInfo here.
// data.framebuffer = fb;
},
Expand Down

0 comments on commit 7bb959e

Please sign in to comment.