Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance update for direct and egl plugin #4421

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/OpenGLWindow/EGLOpenGLWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ void EGLOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
8,
EGL_DEPTH_SIZE,
8,
EGL_SAMPLES,
4,
EGL_SURFACE_TYPE,
EGL_PBUFFER_BIT,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_BIT,
EGL_NONE};
EGL_NONE,
};

EGLint egl_pbuffer_attribs[] = {
EGL_WIDTH,
Expand Down Expand Up @@ -319,6 +322,7 @@ void EGLOpenGLWindow::startRendering()
// printf("EGL window start rendering.\n");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
}

void EGLOpenGLWindow::endRendering()
Expand Down
7 changes: 6 additions & 1 deletion examples/SharedMemory/PhysicsDirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ bool PhysicsDirect::processCamera(const struct SharedMemoryCommand& orgCommand)

// printf("pixel = %d\n", rgbaPixelsReceived[0]);

#if 0
for (int i = 0; i < serverCmd.m_sendPixelDataArguments.m_numPixelsCopied; i++)
{
m_data->m_cachedCameraDepthBuffer[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex] = depthBuffer[i];
Expand All @@ -581,7 +582,11 @@ bool PhysicsDirect::processCamera(const struct SharedMemoryCommand& orgCommand)
{
m_data->m_cachedCameraPixelsRGBA[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex * numBytesPerPixel] = rgbaPixelsReceived[i];
}

#else
memcpy(&m_data->m_cachedCameraDepthBuffer[serverCmd.m_sendPixelDataArguments.m_startingPixelIndex],depthBuffer,serverCmd.m_sendPixelDataArguments.m_numPixelsCopied*sizeof(float));
memcpy(&m_data->m_cachedSegmentationMask[serverCmd.m_sendPixelDataArguments.m_startingPixelIndex],segmentationMaskBuffer,serverCmd.m_sendPixelDataArguments.m_numPixelsCopied*sizeof(int));
memcpy(&m_data->m_cachedCameraPixelsRGBA[serverCmd.m_sendPixelDataArguments.m_startingPixelIndex * numBytesPerPixel],rgbaPixelsReceived,serverCmd.m_sendPixelDataArguments.m_numPixelsCopied * numBytesPerPixel);
#endif
if (serverCmd.m_sendPixelDataArguments.m_numRemainingPixels > 0 && serverCmd.m_sendPixelDataArguments.m_numPixelsCopied)
{
m_data->m_hasStatus = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ struct EGLRendererObjectArray
//#define START_WIDTH 2560
//#define START_HEIGHT 2048

#define START_WIDTH 1024
#define START_HEIGHT 768
#define START_WIDTH (1024*4)
#define START_HEIGHT (1024*4)

struct btHashVisual
{
Expand Down Expand Up @@ -1617,12 +1617,12 @@ void EGLRendererVisualShapeConverter::copyCameraImageDataGL(
BT_PROFILE("resize and flip");
for (int j = 0; j < *heightPtr; j++)
{
int yIndex = int(float(*heightPtr - 1 - j) * (float(sourceHeight) / float(*heightPtr)));
btClamp(yIndex, 0, sourceHeight);
for (int i = 0; i < *widthPtr; i++)
{
int xIndex = int(float(i) * (float(sourceWidth) / float(*widthPtr)));
int yIndex = int(float(*heightPtr - 1 - j) * (float(sourceHeight) / float(*heightPtr)));
btClamp(xIndex, 0, sourceWidth);
btClamp(yIndex, 0, sourceHeight);
int bytesPerPixel = 4; //RGBA

int sourcePixelIndex = (xIndex + yIndex * sourceWidth) * bytesPerPixel;
Expand Down Expand Up @@ -1686,12 +1686,12 @@ void EGLRendererVisualShapeConverter::copyCameraImageDataGL(
BT_PROFILE("resize and flip");
for (int j = 0; j < destinationHeight; j++)
{
int yIndex = int(float(destinationHeight - 1 - j) * (float(sourceHeight) / float(destinationHeight)));
btClamp(yIndex, 0, sourceHeight);
for (int i = 0; i < destinationWidth; i++)
{
int xIndex = int(float(i) * (float(sourceWidth) / float(destinationWidth)));
int yIndex = int(float(destinationHeight - 1 - j) * (float(sourceHeight) / float(destinationHeight)));
btClamp(xIndex, 0, sourceWidth);
btClamp(yIndex, 0, sourceHeight);
int bytesPerPixel = 4; //RGBA
int sourcePixelIndex = (xIndex + yIndex * sourceWidth) * bytesPerPixel;
int sourceDepthIndex = xIndex + yIndex * sourceWidth;
Expand Down
2 changes: 2 additions & 0 deletions examples/pybullet/pybullet.c
Original file line number Diff line number Diff line change
Expand Up @@ -10226,8 +10226,10 @@ static PyObject* pybullet_getCameraImage(PyObject* self, PyObject* args, PyObjec
b3SharedMemoryStatusHandle statusHandle;
int statusType;

Py_BEGIN_ALLOW_THREADS
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
statusType = b3GetStatusType(statusHandle);
Py_END_ALLOW_THREADS
if (statusType == CMD_CAMERA_IMAGE_COMPLETED)
{
PyObject* pyResultList; // store 4 elements in this result: width,
Expand Down