mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
fix forward pass initial layout (#4081)
* fix forward pass initial layout * fix swapchain props not propagated back * reset to default surface whenever binding contexts
This commit is contained in:
@@ -73,12 +73,14 @@ void SwapchainAgent::doInit(const SwapchainInfo &info) {
|
||||
SwapchainTextureInfo textureInfo;
|
||||
textureInfo.swapchain = this;
|
||||
textureInfo.format = _actor->getColorTexture()->getFormat();
|
||||
textureInfo.width = info.width;
|
||||
textureInfo.height = info.height;
|
||||
textureInfo.width = _actor->getWidth();
|
||||
textureInfo.height = _actor->getHeight();
|
||||
initTexture(textureInfo, _colorTexture);
|
||||
|
||||
textureInfo.format = _actor->getDepthStencilTexture()->getFormat();
|
||||
initTexture(textureInfo, _depthStencilTexture);
|
||||
|
||||
_transform = _actor->getSurfaceTransform();
|
||||
}
|
||||
|
||||
void SwapchainAgent::doDestroy() {
|
||||
@@ -112,6 +114,7 @@ void SwapchainAgent::doResize(uint32_t width, uint32_t height, SurfaceTransform
|
||||
auto *depthStencilTexture = static_cast<TextureAgent *>(_depthStencilTexture);
|
||||
colorTexture->_info.width = depthStencilTexture->_info.width = _actor->getWidth();
|
||||
colorTexture->_info.height = depthStencilTexture->_info.height = _actor->getHeight();
|
||||
|
||||
_transform = _actor->getSurfaceTransform();
|
||||
}
|
||||
|
||||
|
||||
@@ -234,8 +234,7 @@ bool GLES2GPUContext::initialize(GLES2GPUStateCache *stateCache, GLES2GPUConstan
|
||||
size_t threadID{std::hash<std::thread::id>{}(std::this_thread::get_id())};
|
||||
_sharedContexts[threadID] = eglDefaultContext;
|
||||
|
||||
makeCurrent(eglDefaultSurface, eglDefaultSurface, eglDefaultContext);
|
||||
resetStates();
|
||||
bindContext(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -270,7 +269,7 @@ void GLES2GPUContext::destroy() {
|
||||
|
||||
void GLES2GPUContext::bindContext(bool bound) {
|
||||
if (bound) {
|
||||
makeCurrent(_eglCurrentDrawSurface, _eglCurrentReadSurface, eglDefaultContext);
|
||||
makeCurrent(eglDefaultSurface, eglDefaultSurface, eglDefaultContext);
|
||||
resetStates();
|
||||
} else {
|
||||
makeCurrent(EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT, false);
|
||||
|
||||
@@ -241,8 +241,7 @@ bool GLES3GPUContext::initialize(GLES3GPUStateCache *stateCache, GLES3GPUConstan
|
||||
size_t threadID{std::hash<std::thread::id>{}(std::this_thread::get_id())};
|
||||
_sharedContexts[threadID] = eglDefaultContext;
|
||||
|
||||
makeCurrent(eglDefaultSurface, eglDefaultSurface, eglDefaultContext);
|
||||
resetStates();
|
||||
bindContext(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -277,7 +276,7 @@ void GLES3GPUContext::destroy() {
|
||||
|
||||
void GLES3GPUContext::bindContext(bool bound) {
|
||||
if (bound) {
|
||||
makeCurrent(_eglCurrentDrawSurface, _eglCurrentReadSurface, eglDefaultContext);
|
||||
makeCurrent(eglDefaultSurface, eglDefaultSurface, eglDefaultContext);
|
||||
resetStates();
|
||||
} else {
|
||||
makeCurrent(EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT, false);
|
||||
|
||||
@@ -55,6 +55,15 @@ void RenderPassValidator::doInit(const RenderPassInfo &info) {
|
||||
}
|
||||
}
|
||||
|
||||
for (auto & attachment : _colorAttachments) {
|
||||
if (attachment.loadOp == LoadOp::LOAD && attachment.beginAccesses.empty()) {
|
||||
CCASSERT(false, "Attachment missing beginAccesses for LoadOp::LOAD");
|
||||
}
|
||||
}
|
||||
if ((_depthStencilAttachment.depthLoadOp == LoadOp::LOAD || _depthStencilAttachment.stencilLoadOp == LoadOp::LOAD) && _depthStencilAttachment.beginAccesses.empty()) {
|
||||
CCASSERT(false, "Attachment missing beginAccesses for LoadOp::LOAD");
|
||||
}
|
||||
|
||||
/////////// execute ///////////
|
||||
|
||||
_actor->initialize(info);
|
||||
|
||||
@@ -69,12 +69,14 @@ void SwapchainValidator::doInit(const SwapchainInfo &info) {
|
||||
SwapchainTextureInfo textureInfo;
|
||||
textureInfo.swapchain = this;
|
||||
textureInfo.format = _actor->getColorTexture()->getFormat();
|
||||
textureInfo.width = info.width;
|
||||
textureInfo.height = info.height;
|
||||
textureInfo.width = _actor->getWidth();
|
||||
textureInfo.height = _actor->getHeight();
|
||||
initTexture(textureInfo, _colorTexture);
|
||||
|
||||
textureInfo.format = _actor->getDepthStencilTexture()->getFormat();
|
||||
initTexture(textureInfo, _depthStencilTexture);
|
||||
|
||||
_transform = _actor->getSurfaceTransform();
|
||||
}
|
||||
|
||||
void SwapchainValidator::doDestroy() {
|
||||
|
||||
@@ -179,6 +179,7 @@ void ForwardStage::render(scene::Camera *camera) {
|
||||
colorAttachmentInfo.loadOp = gfx::LoadOp::DISCARD;
|
||||
} else {
|
||||
colorAttachmentInfo.loadOp = gfx::LoadOp::LOAD;
|
||||
colorAttachmentInfo.beginAccesses = {gfx::AccessType::COLOR_ATTACHMENT_WRITE};
|
||||
}
|
||||
}
|
||||
colorAttachmentInfo.endAccesses = {gfx::AccessType::COLOR_ATTACHMENT_WRITE};
|
||||
|
||||
Reference in New Issue
Block a user