Permalink
Browse files

project clean up (output and temp dirs), perf_tests improvements, add…

…ed test images (lenna)
  • Loading branch information...
fenbf committed Sep 28, 2013
1 parent 0b7784f commit fe3b6ea9bbca56fcf0f661f1ac779880648faf20
BIN +219 KB lenna1.jpg
Binary file not shown.
BIN +147 KB lenna2.jpg
Binary file not shown.
BIN +176 KB lenna3.jpg
Binary file not shown.
BIN +195 KB lennabig.jpg
Binary file not shown.
@@ -68,16 +68,16 @@
<_ProjectFileVersion>11.0.60610.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
@@ -41,9 +41,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -41,9 +41,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -1957,52 +1957,59 @@ int soilIsExtensionSupported(const char *name)
}
#ifdef WIN32
// from glload
static int soilTestWinProcPointer(const PROC pTest)
{
ptrdiff_t iTest;
if(!pTest) return 0;
iTest = (ptrdiff_t)pTest;
// from glload
static int soilTestWinProcPointer(const PROC pTest)
{
ptrdiff_t iTest;
if(!pTest) return 0;
iTest = (ptrdiff_t)pTest;
if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0;
if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0;
return 1;
}
return 1;
}
#endif
void *soilLoadProcAddr(const char *procName)
{
void *soilLoadProcAddr(const char *procName)
{
#ifdef WIN32
PROC p = wglGetProcAddress(procName);
PROC p = wglGetProcAddress(procName);
if (soilTestWinProcPointer(p))
return p;
else
return NULL;
#elif defined(__APPLE__) || defined(__APPLE_CC__)
#elif defined(__APPLE__) || defined(__APPLE_CC__)
/* modified for deprecated methods */
CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
CFSTR("/System/Library/Frameworks/OpenGL.framework"),
kCFURLPOSIXPathStyle,
true );
CFSTR("/System/Library/Frameworks/OpenGL.framework"),
kCFURLPOSIXPathStyle,
true );
CFStringRef extensionName = CFStringCreateWithCString(kCFAllocatorDefault,
procName,
kCFStringEncodingASCII );
procName,
kCFStringEncodingASCII );
CFBundleRef bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL );
assert( bundle != NULL );
void *ext_addr = CFBundleGetFunctionPointerForName(bundle, extensionName);
CFRelease( bundleURL );
CFRelease( extensionName );
CFRelease( bundle );
return ext_addr;
#else // linux:
return glXGetProcAddressARB(procName);
#endif
}
#elif defined ( linux ) || defined( __linux__ )
#if !defined(GLX_VERSION_1_4)
return glXGetProcAddressARB( (const GLubyte *)procName );
#else
return glXGetProcAddress( (const GLubyte *)procName );
#endif
#else
return NULL; // unsupported
#endif
}
int query_NPOT_capability( void )
{
@@ -3,6 +3,7 @@
#include <io.h>
#include <vector>
#include <chrono>
#include <iomanip>
#include <windows.h>
#include <shellapi.h>
@@ -148,21 +149,61 @@ void DisableOpenGL (HWND hwnd, HDC hDC, HGLRC hRC)
ReleaseDC(hwnd, hDC);
}
void LoadTest(const std::vector<std::string> &files, const int numFiles, const int numLoads, GLuint *texID, unsigned int soilFlags, long *duration)
void CalculateTextureObjectPixels(GLuint texID, unsigned long *pixelCount, unsigned long *memoryUsed)
{
auto t_start = std::chrono::high_resolution_clock::now();
int baseLevel = 0, maxLevel = 0;
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &baseLevel);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &maxLevel);
long pixels = 0, bytes = 0, bpp = 0;
int texW = 0, texH = 0, texFmt = 0;
for (int level = baseLevel; level <= maxLevel; ++level)
{
glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_WIDTH, &texW);
glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_HEIGHT, &texH);
glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &texFmt);
pixels += texW*texH;
if (texFmt == GL_RGB || texFmt == GL_RGB8)
bpp = 3;
else if (texFmt == GL_RGBA || texFmt == GL_RGBA8)
bpp = 4;
else
bpp = 0;
bytes += texW*texH*bpp;
if (texW == 1 && texH == 1)
break;
}
*pixelCount += pixels;
*memoryUsed += bytes;
}
void LoadTest(const std::vector<std::string> &files, const int numLoads, GLuint *texID, unsigned int soilFlags, long *duration, unsigned long *pixels, unsigned long *pixelsMem)
{
long durationMilisec = 0;
unsigned long pixelsLoaded = 0;
unsigned int texW = 0, texH = 0;
size_t numFiles = files.size();
for (int i = 0; i < numLoads; ++i)
{
texID[i] = SOIL_load_OGL_texture(files[i%numFiles].c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, soilFlags);
auto t_start = std::chrono::high_resolution_clock::now();
{
texID[i] = SOIL_load_OGL_texture(files[i%numFiles].c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, soilFlags);
}
auto t_end = std::chrono::high_resolution_clock::now();
durationMilisec += static_cast<long>(std::chrono::duration_cast<std::chrono::milliseconds>(t_end - t_start).count());
if (texID[i] == 0)
std::cout << "error!, could not load " << files[i%numFiles] << std::endl;
}
auto t_end = std::chrono::high_resolution_clock::now();
CalculateTextureObjectPixels(texID[i], pixels, pixelsMem);
}
*duration = static_cast<long>(std::chrono::duration_cast<std::chrono::milliseconds>(t_end - t_start).count());
*duration = durationMilisec;
*pixels = pixelsLoaded;
}
void BuildFileLIst(std::vector<std::string> *files, std::string pattern)
@@ -194,7 +235,7 @@ void BuildFileLIst(std::vector<std::string> *files, std::string pattern)
void DoTest(std::vector<std::string> args)
{
const int NUM_FILES = 3;
const char *defaultFiles[NUM_FILES] = { "test1.jpg", "test2.jpg", "test3.jpg" };
const char *defaultFiles[NUM_FILES] = { "lenna1.jpg", "lenna2.jpg", "lenna3.jpg" };
std::vector<std::string> files;
const int NUM_LOADS = args.size() > 0 ? atoi(args[0].c_str()) : 100;
@@ -212,15 +253,31 @@ void DoTest(std::vector<std::string> args)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
long duration = 0;
unsigned long pixels = 0, pixelsMem = 0;
double pixSpeed = 0.0, memSpeed = 0.0, mem = 0.0;
std::vector<unsigned int> texID(NUM_LOADS);
LoadTest(files, NUM_FILES, NUM_LOADS, texID.data(), SOIL_FLAG_GL_MIPMAPS, &duration);
std::cout << "SOIL_FLAG_GL_MIPMAPS : " << duration << "ms" << std::endl;
std::cout.precision(2);
pixels = 0;
pixelsMem = 0;
LoadTest(files, NUM_LOADS, texID.data(), SOIL_FLAG_GL_MIPMAPS, &duration, &pixels, &pixelsMem);
pixSpeed = pixels/((double)duration*0.001);
mem = pixelsMem/(double)(1024.0*1024);
memSpeed = mem/(double)(duration*0.001);
//std::cout << "FLAG_GL_MIPMAPS:\t" << duration*0.001 << "sec, memory:\t" << std::fixed << mem << "MB speed:\t" << std::fixed << memSpeed << " MB/s" << std::endl;
printf("FLAG_GL_MIPMAPS: %2.2fsec, memory: %3.2f MB, speed %3.3f MB/s\n", (float)(duration*0.001), (float)mem, (float)memSpeed);
for (int i = 0; i < NUM_LOADS; ++i)
glDeleteTextures(1, &texID[i]);
LoadTest(files, NUM_FILES, NUM_LOADS, texID.data(), SOIL_FLAG_MIPMAPS, &duration);
std::cout << "SOIL_FLAG_MIPMAPS : " << duration << "ms" << std::endl;
pixels = 0;
pixelsMem = 0;
LoadTest(files, NUM_LOADS, texID.data(), SOIL_FLAG_MIPMAPS, &duration, &pixels, &pixelsMem);
pixSpeed = pixels/((double)duration*0.001);
mem = pixelsMem/(double)(1024.0*1024);
memSpeed = mem/(double)(duration*0.001);
//std::cout << "FLAG_MIPMAPS: \t" << duration*0.001 << "sec, memory:\t" << std::fixed << mem << "MB speed:\t" << std::fixed << memSpeed << " MB/s" << std::endl;
printf("FLAG_MIPMAPS: %2.2fsec, memory: %3.2f MB, speed %3.3f MB/s\n", (float)(duration*0.001), (float)mem, (float)memSpeed);
for (int i = 0; i < NUM_LOADS; ++i)
glDeleteTextures(1, &texID[i]);

0 comments on commit fe3b6ea

Please sign in to comment.