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 Aug 9, 2023
1 parent 53f45e9 commit 8977200
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 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 @@ -1594,7 +1594,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 @@ -1620,7 +1625,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

0 comments on commit 8977200

Please sign in to comment.