Merge pull request #3042 from erwincoumans/master

fix shadowmap /mipmap issue in previous commit, caused Mac OSX (and integrated GPUs) to become very slow
This commit is contained in:
erwincoumans
2020-09-09 09:48:59 -07:00
committed by GitHub
3 changed files with 60 additions and 24 deletions

View File

@@ -1624,10 +1624,6 @@ void GLInstancingRenderer::renderScene()
{
renderSceneInternal(B3_CREATE_SHADOWMAP_RENDERMODE);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_data->m_shadowTexture);
glGenerateMipmap(GL_TEXTURE_2D);
if (m_planeReflectionShapeIndex >= 0)
{
/* Don't update color or depth. */
@@ -2361,12 +2357,21 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
if (gfxObj->m_flags & B3_INSTANCE_TEXTURE)
{
curBindTexture = m_data->m_textureHandles[gfxObj->m_textureIndex].m_glTexture;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glBindTexture(GL_TEXTURE_2D, curBindTexture);
if (m_data->m_textureHandles[gfxObj->m_textureIndex].m_enableFiltering)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
if (renderMode == B3_CREATE_SHADOWMAP_RENDERMODE)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
else
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
@@ -2378,13 +2383,12 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
else
{
curBindTexture = m_data->m_defaultTexturehandle;
glBindTexture(GL_TEXTURE_2D, curBindTexture);
}
//disable lazy evaluation, it just leads to bugs
//if (lastBindTexture != curBindTexture)
{
glBindTexture(GL_TEXTURE_2D, curBindTexture);
}
//lastBindTexture = curBindTexture;
b3Assert(glGetError() == GL_NO_ERROR);

View File

@@ -13,6 +13,7 @@
#include "../MultiThreading/b3ThreadSupportInterface.h"
#include "SharedMemoryPublic.h"
//#define BT_ENABLE_VR
#define SYNC_CAMERA_USING_GUI_CS
#ifdef BT_ENABLE_VR
#include "../RenderingExamples/TinyVRGui.h"
#endif //BT_ENABLE_VR
@@ -740,18 +741,19 @@ public:
MultiThreadedOpenGLGuiHelper(CommonGraphicsApp* app, GUIHelperInterface* guiHelper, int skipGraphicsUpdate)
: //m_app(app),
m_cs(0),
m_cs2(0),
m_cs3(0),
m_csGUI(0),
m_debugDraw(0),
m_uidGenerator(0),
m_texels(0),
m_shapeIndex(-1),
m_textureId(-1),
m_instanceId(-1),
m_skipGraphicsUpdate(skipGraphicsUpdate)
m_cs(0),
m_cs2(0),
m_cs3(0),
m_csGUI(0),
m_debugDraw(0),
m_uidGenerator(0),
m_texels(0),
m_shapeIndex(-1),
m_textureId(-1),
m_instanceId(-1),
m_skipGraphicsUpdate(skipGraphicsUpdate)
{
m_cameraUpdated = 0;
m_childGuiHelper = guiHelper;
}
@@ -805,6 +807,12 @@ public:
{
return m_cs3;
}
b3CriticalSection* getCriticalSectionGUI()
{
return m_csGUI;
}
btRigidBody* m_body;
btVector3 m_color3;
virtual void createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color)
@@ -1087,6 +1095,8 @@ public:
{
m_childGuiHelper->setUpAxis(axis);
}
bool m_cameraUpdated;
float m_resetCameraCamDist;
float m_resetCameraYaw;
float m_resetCameraPitch;
@@ -1096,16 +1106,22 @@ public:
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ)
{
m_cs->lock();
m_csGUI->lock();
m_cameraUpdated = true;
m_resetCameraCamDist = camDist;
m_resetCameraYaw = yaw;
m_resetCameraPitch = pitch;
m_resetCameraCamPosX = camPosX;
m_resetCameraCamPosY = camPosY;
m_resetCameraCamPosZ = camPosZ;
#ifdef SYNC_CAMERA_USING_GUI_CS
m_csGUI->unlock();
#else
m_cs->setSharedParam(1, eGUIHelperResetCamera);
workerThreadWait();
//m_childGuiHelper->resetCamera(camDist, yaw, pitch, camPosX, camPosY, camPosZ);
m_childGuiHelper->resetCamera(camDist, yaw, pitch, camPosX, camPosY, camPosZ);
#endif //SYNC_CAMERA_USING_GUI_CS
}
virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3], float hor[3], float vert[3], float* yaw, float* pitch, float* camDist, float camTarget[3]) const
@@ -1948,6 +1964,21 @@ void PhysicsServerExample::updateGraphics()
{
//check if any graphics related tasks are requested
#ifdef SYNC_CAMERA_USING_GUI_CS
m_multiThreadedHelper->getCriticalSectionGUI()->lock();
if (m_multiThreadedHelper->m_cameraUpdated)
{
m_multiThreadedHelper->m_cameraUpdated = false;
m_multiThreadedHelper->m_childGuiHelper->resetCamera(
m_multiThreadedHelper->m_resetCameraCamDist,
m_multiThreadedHelper->m_resetCameraYaw,
m_multiThreadedHelper->m_resetCameraPitch,
m_multiThreadedHelper->m_resetCameraCamPosX,
m_multiThreadedHelper->m_resetCameraCamPosY,
m_multiThreadedHelper->m_resetCameraCamPosZ);
}
m_multiThreadedHelper->getCriticalSectionGUI()->unlock();
#endif
switch (m_multiThreadedHelper->getCriticalSection()->getSharedParam(1))
{
case eGUIHelperCreateCollisionShapeGraphicsObject:
@@ -2587,6 +2618,7 @@ void PhysicsServerExample::stepSimulation(float deltaTime)
}
updateGraphics();
{
if (m_multiThreadedHelper->m_childGuiHelper->getRenderInterface())
{

View File

@@ -501,7 +501,7 @@ if 'BT_USE_EGL' in EGL_CXX_FLAGS:
setup(
name='pybullet',
version='2.9.4',
version='2.9.5',
description=
'Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning',
long_description=