mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
misc gfx fixes (#3991)
* better hashing strat * gfx: unify states hash * vk: upload texture in multiple chunks if needed * gfx: states lifecycle management
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "PipelineStateManager.h"
|
||||
#include "RenderFlow.h"
|
||||
#include "RenderPipeline.h"
|
||||
#include "frame-graph/FrameGraph.h"
|
||||
#include "gfx-base/GFXCommandBuffer.h"
|
||||
#include "gfx-base/GFXDescriptorSet.h"
|
||||
#include "gfx-base/GFXDescriptorSetLayout.h"
|
||||
@@ -106,6 +107,8 @@ void RenderPipeline::render(const vector<scene::Camera *> &cameras) {
|
||||
flow->render(camera);
|
||||
}
|
||||
}
|
||||
|
||||
RenderPipeline::framegraphGC();
|
||||
}
|
||||
|
||||
void RenderPipeline::destroyQuadInputAssembler() {
|
||||
@@ -145,8 +148,6 @@ void RenderPipeline::destroy() {
|
||||
|
||||
CC_SAFE_DESTROY(_defaultTexture);
|
||||
|
||||
CC_SAFE_DELETE(_defaultTexture);
|
||||
|
||||
PipelineStateManager::destroyAll();
|
||||
InstancedBuffer::destroyInstancedBuffer();
|
||||
}
|
||||
@@ -179,10 +180,7 @@ gfx::InputAssembler *RenderPipeline::getIAByRenderArea(const gfx::Rect &renderAr
|
||||
static_cast<float>(renderArea.height) / bufferHeight,
|
||||
};
|
||||
|
||||
size_t hash = boost::hash_range(reinterpret_cast<const uint64_t *>(&viewport.x),
|
||||
reinterpret_cast<const uint64_t *>(&viewport.x + 4));
|
||||
|
||||
const auto iter = _quadIA.find(hash);
|
||||
const auto iter = _quadIA.find(viewport);
|
||||
if (iter != _quadIA.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
@@ -191,7 +189,7 @@ gfx::InputAssembler *RenderPipeline::getIAByRenderArea(const gfx::Rect &renderAr
|
||||
gfx::InputAssembler *ia = nullptr;
|
||||
createQuadInputAssembler(_quadIB, &vb, &ia);
|
||||
_quadVB.push_back(vb);
|
||||
_quadIA[hash] = ia;
|
||||
_quadIA[viewport] = ia;
|
||||
|
||||
updateQuadVertexData(viewport, vb);
|
||||
|
||||
@@ -208,10 +206,6 @@ bool RenderPipeline::createQuadInputAssembler(gfx::Buffer *quadIB, gfx::Buffer *
|
||||
gfx::MemoryUsageBit::DEVICE, vbSize, vbStride});
|
||||
}
|
||||
|
||||
if (*quadVB == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// step 2 create input assembler
|
||||
gfx::InputAssemblerInfo info;
|
||||
info.attributes.push_back({"a_position", gfx::Format::RG32F});
|
||||
@@ -333,5 +327,13 @@ bool RenderPipeline::isOccluded(const scene::Camera *camera, const scene::SubMod
|
||||
return _queryPools[0]->getResult(id) == 0;
|
||||
}
|
||||
|
||||
void RenderPipeline::framegraphGC() {
|
||||
static uint64_t frameCount{0U};
|
||||
static constexpr uint32_t INTERVAL_IN_SECONDS = 30;
|
||||
if (++frameCount % (INTERVAL_IN_SECONDS * 60)) {
|
||||
framegraph::FrameGraph::gc(INTERVAL_IN_SECONDS * 60);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace cc
|
||||
|
||||
Reference in New Issue
Block a user