Fix cube map render and rendering the same camera with two GSGs

The problem was that the cull result was being reused across different lens indices and GSGs
This commit is contained in:
rdb 2016-07-09 14:42:25 +02:00
parent 11861cb73d
commit 44d59edc30
2 changed files with 26 additions and 3 deletions

View File

@ -18,6 +18,7 @@ This issue fixes several bugs that were still found in 1.9.2.
* Fix crashes with pbuffers on Intel cards on Windows
* Support for Autodesk Maya 2016.5
* Add shadow-depth-bits config var to control shadow map depth
* No longer reuses cull result for different GSG or lens index
------------------------ RELEASE 1.9.2 ------------------------

View File

@ -120,6 +120,23 @@ PStatCollector GraphicsEngine::_occlusion_passed_pcollector("Occlusion results:V
PStatCollector GraphicsEngine::_occlusion_failed_pcollector("Occlusion results:Occluded");
PStatCollector GraphicsEngine::_occlusion_tests_pcollector("Occlusion tests");
// This is used to keep track of which scenes we have already culled.
struct CullKey {
GraphicsStateGuardian *_gsg;
NodePath _camera;
int _lens_index;
};
INLINE static bool operator < (const CullKey &a, const CullKey &b) {
if (a._gsg != b._gsg) {
return a._gsg < b._gsg;
}
if (a._camera != b._camera) {
return a._camera < b._camera;
}
return a._lens_index < b._lens_index;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsEngine::Constructor
// Access: Published
@ -1487,7 +1504,7 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
// Keep track of the cameras we have already used in this thread to
// render DisplayRegions.
typedef pmap<NodePath, DisplayRegion *> AlreadyCulled;
typedef pmap<CullKey, DisplayRegion *> AlreadyCulled;
AlreadyCulled already_culled;
size_t wlist_size = wlist.size();
@ -1501,8 +1518,13 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
if (dr != (DisplayRegion *)NULL) {
DisplayRegionPipelineReader *dr_reader =
new DisplayRegionPipelineReader(dr, current_thread);
NodePath camera = dr_reader->get_camera();
AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(camera, (DisplayRegion *)NULL)).first;
CullKey key;
key._gsg = win->get_gsg();
key._camera = dr_reader->get_camera();
key._lens_index = dr_reader->get_lens_index();
AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(key, (DisplayRegion *)NULL)).first;
if ((*aci).second == NULL) {
// We have not used this camera already in this thread.
// Perform the cull operation.