mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Fix current drawable access issue
This commit is contained in:
@@ -72,6 +72,7 @@ public:
|
||||
CC_INLINE bool isCommandBufferBegan() const { return _commandBufferBegan; }
|
||||
CC_INLINE id<MTLCommandBuffer> getMTLCommandBuffer() const { return _mtlCommandBuffer; }
|
||||
id<CAMetalDrawable> getCurrentDrawable();
|
||||
void disposeCurrentDrawable();
|
||||
|
||||
private:
|
||||
void bindDescriptorSets();
|
||||
|
||||
@@ -74,6 +74,13 @@ id<CAMetalDrawable> CCMTLCommandBuffer::getCurrentDrawable() {
|
||||
return _currDrawable;
|
||||
}
|
||||
|
||||
void CCMTLCommandBuffer::disposeCurrentDrawable() {
|
||||
if (_currDrawable) {
|
||||
[_currDrawable release];
|
||||
_currDrawable = nil;
|
||||
}
|
||||
}
|
||||
|
||||
bool CCMTLCommandBuffer::isRenderingEntireDrawable(const Rect &rect, const CCMTLRenderPass *renderPass) {
|
||||
const int num = renderPass->getColorRenderTargetNums();
|
||||
if (num == 0) {
|
||||
@@ -118,11 +125,7 @@ void CCMTLCommandBuffer::end() {
|
||||
// Secondary command buffer should end encoding here
|
||||
_commandEncoder.endEncoding();
|
||||
}
|
||||
|
||||
if (_currDrawable) {
|
||||
[_currDrawable release];
|
||||
_currDrawable = nil;
|
||||
}
|
||||
disposeCurrentDrawable();
|
||||
|
||||
if (_autoreleasePool) {
|
||||
// CC_LOG_INFO("%d CB POOL: %p RELEASED for %p", [NSThread currentThread], _autoreleasePool, this);
|
||||
|
||||
@@ -248,6 +248,7 @@ void CCMTLDevice::present() {
|
||||
_inFlightSemaphore->signal();
|
||||
}];
|
||||
[mtlCommandBuffer commit];
|
||||
cmdBuff->disposeCurrentDrawable();
|
||||
|
||||
if (_autoreleasePool) {
|
||||
// CC_LOG_INFO("POOL: %p RELEASED", _autoreleasePool);
|
||||
|
||||
Reference in New Issue
Block a user