rendertest + parallel pip + no debug for plugin

This commit is contained in:
Max Argus
2018-07-17 10:48:28 +02:00
parent 35b30359e3
commit e15fb0866c
3 changed files with 51 additions and 35 deletions

View File

@@ -937,10 +937,10 @@ void TinyRendererVisualShapeConverter::render(const float viewMat[16], const flo
m_data->m_instancingRenderer->updateCamera(); m_data->m_instancingRenderer->updateCamera();
m_data->m_instancingRenderer->renderScene(); m_data->m_instancingRenderer->renderScene();
cout<<viewMat[4*0 + 0]<<" "<<viewMat[4*0+1]<<" "<<viewMat[4*0+2]<<" "<<viewMat[4*0+3] << endl; //cout<<viewMat[4*0 + 0]<<" "<<viewMat[4*0+1]<<" "<<viewMat[4*0+2]<<" "<<viewMat[4*0+3] << endl;
cout<<viewMat[4*1 + 0]<<" "<<viewMat[4*1+1]<<" "<<viewMat[4*1+2]<<" "<<viewMat[4*1+3] << endl; //cout<<viewMat[4*1 + 0]<<" "<<viewMat[4*1+1]<<" "<<viewMat[4*1+2]<<" "<<viewMat[4*1+3] << endl;
cout<<viewMat[4*2 + 0]<<" "<<viewMat[4*2+1]<<" "<<viewMat[4*2+2]<<" "<<viewMat[4*2+3] << endl; //cout<<viewMat[4*2 + 0]<<" "<<viewMat[4*2+1]<<" "<<viewMat[4*2+2]<<" "<<viewMat[4*2+3] << endl;
cout<<viewMat[4*3 + 0]<<" "<<viewMat[4*3+1]<<" "<<viewMat[4*3+2]<<" "<<viewMat[4*3+3] << endl; //cout<<viewMat[4*3 + 0]<<" "<<viewMat[4*3+1]<<" "<<viewMat[4*3+2]<<" "<<viewMat[4*3+3] << endl;
} }
void TinyRendererVisualShapeConverter::getWidthAndHeight(int& width, int& height) void TinyRendererVisualShapeConverter::getWidthAndHeight(int& width, int& height)
@@ -998,7 +998,7 @@ void TinyRendererVisualShapeConverter::copyCameraImageDataGL(
// Copied from SimpleOpenGL3App::getScreenPixels // Copied from SimpleOpenGL3App::getScreenPixels
b3Assert((sourceWidth*sourceHeight*4) == rgbaBufferSizeInPixels); b3Assert((sourceWidth*sourceHeight*4) == rgbaBufferSizeInPixels);
//glClear(GL_COLOR_BUFFER_BIT); //glClear(GL_COLOR_BUFFER_BIT);
b3Warning("EGL\n"); //b3Warning("EGL\n");
if ((sourceWidth*sourceHeight*4) == rgbaBufferSizeInPixels) // remove this if if ((sourceWidth*sourceHeight*4) == rgbaBufferSizeInPixels) // remove this if
{ {
glReadPixels(0,0,sourceWidth, sourceHeight, GL_RGBA, GL_UNSIGNED_BYTE, &(sourceRgbaPixelBuffer[0])); glReadPixels(0,0,sourceWidth, sourceHeight, GL_RGBA, GL_UNSIGNED_BYTE, &(sourceRgbaPixelBuffer[0]));

View File

@@ -37,7 +37,6 @@ class BulletSim():
print("connecting") print("connecting")
optionstring='--width={} --height={}'.format(pixelWidth,pixelHeight) optionstring='--width={} --height={}'.format(pixelWidth,pixelHeight)
optionstring += ' --window_backend=2 --render_device=0' optionstring += ' --window_backend=2 --render_device=0'
#optionstring += ' --window_backend=X11 --render_device=0'
print(self.connection_mode, optionstring,*self.argv) print(self.connection_mode, optionstring,*self.argv)
cid = pybullet.connect(self.connection_mode, options=optionstring,*self.argv) cid = pybullet.connect(self.connection_mode, options=optionstring,*self.argv)
@@ -58,7 +57,10 @@ class BulletSim():
def __exit__(self,*_,**__): def __exit__(self,*_,**__):
pybullet.disconnect() pybullet.disconnect()
def test(num_runs=100, shadow=1, plot=False): def test(num_runs=100, shadow=1, log=True, plot=False):
if log:
logId = pybullet.startStateLogging(pybullet.STATE_LOGGING_PROFILE_TIMINGS, "renderTimings")
if plot: if plot:
plt.ion() plt.ion()
@@ -102,39 +104,31 @@ def test(num_runs=100, shadow=1, plot=False):
print("mean: {0} for {1} runs".format(np.mean(times), num_runs)) print("mean: {0} for {1} runs".format(np.mean(times), num_runs))
print("") print("")
if log:
pybullet.stopStateLogging(logId)
if __name__ == "__main__": if __name__ == "__main__":
'''
with BulletSim(pybullet.DIRECT): with BulletSim(pybullet.DIRECT):
print("Testing DIRECT w/ shadow") print("\nTesting DIRECT")
test() test(log=False)
print("Testing DIRECT w/o shadow")
test(shadow=0) with BulletSim(pybullet.DIRECT):
plugin_fn = '/home/argusm/lang/bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so'
plugin = pybullet.loadPlugin(plugin_fn,"_tinyRendererPlugin")
if plugin < 0:
print("\nPlugin Failed to load!\n")
sys.exit()
print("\nTesting DIRECT+OpenGL")
test()
with BulletSim(pybullet.GUI): with BulletSim(pybullet.GUI):
print("Testing GUI") # could have OpenGL? print("\nTesting GUI")
test() test(log=False)
print("Testing GUI w/o shadow") # could have OpenGL?
test(shadow=0)
server_bin = "../../../build_cmake/examples/ExampleBrowser/App_ExampleBrowser"
server_f = lambda : subprocess.run([server_bin],shell=True)
server = Process(target=server_f)
#server.start()
'''
with BulletSim(pybullet.GUI):
logId = pybullet.startStateLogging(pybullet.STATE_LOGGING_PROFILE_TIMINGS, "renderTimings")
print("Testing GUI")
test()
print("Testing GUI w/o shadow")
test(shadow=0)
pybullet.stopStateLogging(logId)
#server.join()

View File

@@ -2,12 +2,32 @@
from setuptools import find_packages from setuptools import find_packages
from sys import platform as _platform from sys import platform as _platform
import sys import sys
import glob from glob import glob
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from distutils.util import get_platform from distutils.util import get_platform
from glob import glob
# monkey-patch for parallel compilation
import multiprocessing
import multiprocessing.pool
def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None):
# those lines are copied from distutils.ccompiler.CCompiler directly
macros, objects, extra_postargs, pp_opts, build = self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs)
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
# parallel code
N = 2*multiprocessing.cpu_count()# number of parallel compilations
def _single_compile(obj):
try: src, ext = build[obj]
except KeyError: return
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
# convert to list, imap is evaluated on-demand
list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects))
return objects
import distutils.ccompiler
distutils.ccompiler.CCompiler.compile=parallelCCompile
#see http://stackoverflow.com/a/8719066/295157 #see http://stackoverflow.com/a/8719066/295157
import os import os
@@ -508,6 +528,8 @@ eglRender = Extension("eglRenderer",
extra_compile_args=(CXX_FLAGS+'-DBT_USE_EGL -DSTB_AGAIN -DB3_DEBUG').split(), extra_compile_args=(CXX_FLAGS+'-DBT_USE_EGL -DSTB_AGAIN -DB3_DEBUG').split(),
include_dirs = include_dirs + ["src","examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"] include_dirs = include_dirs + ["src","examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"]
) )
setup( setup(
name = 'pybullet', name = 'pybullet',
version='2.1.3', version='2.1.3',