mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
GL: better subpass support (#3887)
* vk: better subpass dependency deduction * GL: better subpass support * uint -> uint32_t * officially make viewport/scissor dynamic by default * gfx: states store hashes * gfx: defend against usages after destroy
This commit is contained in:
@@ -47,7 +47,7 @@ BufferValidator::~BufferValidator() {
|
||||
DeviceResourceTracker<Buffer>::erase(this);
|
||||
CC_SAFE_DELETE(_actor);
|
||||
|
||||
uint lifeTime = DeviceValidator::getInstance()->currentFrame() - _creationFrame;
|
||||
uint32_t lifeTime = DeviceValidator::getInstance()->currentFrame() - _creationFrame;
|
||||
// skip those that have never been updated
|
||||
if (!_isBufferView && hasFlag(_memUsage, MemoryUsageBit::HOST) && _totalUpdateTimes && _totalUpdateTimes < lifeTime / 3) {
|
||||
CC_LOG_WARNING("Triple buffer enabled for infrequently-updated buffer, consider using MemoryUsageBit::DEVICE instead");
|
||||
@@ -56,13 +56,16 @@ BufferValidator::~BufferValidator() {
|
||||
}
|
||||
|
||||
void BufferValidator::doInit(const BufferInfo &info) {
|
||||
CCASSERT(!isInited(), "initializing twice?");
|
||||
_inited = true;
|
||||
|
||||
CCASSERT(info.usage != BufferUsageBit::NONE, "invalid buffer param");
|
||||
CCASSERT(info.memUsage != MemoryUsageBit::NONE, "invalid buffer param");
|
||||
// CCASSERT(info.size, "zero-sized buffer?"); // be more lenient on this for now
|
||||
|
||||
_initStack = se::ScriptEngine::getInstance()->getCurrentStackTrace();
|
||||
|
||||
_creationFrame = DeviceValidator::getInstance()->currentFrame();
|
||||
_creationFrame = DeviceValidator::getInstance()->currentFrame();
|
||||
_totalUpdateTimes = 0U;
|
||||
|
||||
if (hasFlag(info.usage, BufferUsageBit::VERTEX) && !info.stride) {
|
||||
@@ -75,7 +78,11 @@ void BufferValidator::doInit(const BufferInfo &info) {
|
||||
}
|
||||
|
||||
void BufferValidator::doInit(const BufferViewInfo &info) {
|
||||
CCASSERT(!isInited(), "initializing twice?");
|
||||
_inited = true;
|
||||
|
||||
CCASSERT(info.buffer, "invalid source buffer");
|
||||
CCASSERT(static_cast<BufferValidator *>(info.buffer)->isInited(), "already destroyed?");
|
||||
CCASSERT(info.offset + info.range <= info.buffer->getSize(), "invalid range");
|
||||
|
||||
/////////// execute ///////////
|
||||
@@ -86,7 +93,9 @@ void BufferValidator::doInit(const BufferViewInfo &info) {
|
||||
_actor->initialize(actorInfo);
|
||||
}
|
||||
|
||||
void BufferValidator::doResize(uint size, uint /*count*/) {
|
||||
void BufferValidator::doResize(uint32_t size, uint32_t /*count*/) {
|
||||
CCASSERT(isInited(), "alread destroyed?");
|
||||
|
||||
CCASSERT(!_isBufferView, "cannot resize through buffer views");
|
||||
CCASSERT(size, "invalid size");
|
||||
|
||||
@@ -96,10 +105,17 @@ void BufferValidator::doResize(uint size, uint /*count*/) {
|
||||
}
|
||||
|
||||
void BufferValidator::doDestroy() {
|
||||
CCASSERT(isInited(), "destroying twice?");
|
||||
_inited = false;
|
||||
|
||||
/////////// execute ///////////
|
||||
|
||||
_actor->destroy();
|
||||
}
|
||||
|
||||
void BufferValidator::update(const void *buffer, uint size) {
|
||||
void BufferValidator::update(const void *buffer, uint32_t size) {
|
||||
CCASSERT(isInited(), "alread destroyed?");
|
||||
|
||||
CCASSERT(!_isBufferView, "cannot update through buffer views");
|
||||
CCASSERT(size && size <= _size, "invalid size");
|
||||
CCASSERT(buffer, "invalid buffer data");
|
||||
@@ -123,8 +139,8 @@ void BufferValidator::update(const void *buffer, uint size) {
|
||||
_actor->update(buffer, size);
|
||||
}
|
||||
|
||||
void BufferValidator::sanityCheck(const void *buffer, uint size) {
|
||||
uint cur = DeviceValidator::getInstance()->currentFrame();
|
||||
void BufferValidator::sanityCheck(const void *buffer, uint32_t size) {
|
||||
uint32_t cur = DeviceValidator::getInstance()->currentFrame();
|
||||
|
||||
if (cur == _lastUpdateFrame) {
|
||||
// FIXME: minggo: as current implementation need to update some buffers more than once, so disable it.
|
||||
|
||||
Reference in New Issue
Block a user