.gitignore | 2 .travis.yml | 59 BUGS.markdown | 210 CMakeLists.txt | 402 DEVELOPMENT.markdown | 169 Dalvik.markdown | 55 INSTALL.markdown | 142 NEWS.markdown | 72 README.markdown | 524 TODO.markdown | 1 appveyor.yml | 38 cli/CMakeLists.txt | 23 cli/cli.hpp | 4 cli/cli_diff.cpp | 10 cli/cli_diff_images.cpp | 10 cli/cli_diff_state.cpp | 71 cli/cli_dump.cpp | 14 cli/cli_pager.cpp | 47 cli/cli_pager.hpp | 4 cli/cli_pickle.cpp | 30 cli/cli_resources.cpp | 7 cli/cli_resources.hpp | 4 cli/cli_retrace.hpp | 4 cli/cli_sed.cpp | 59 cli/cli_trace.cpp | 114 cli/pickle.hpp | 65 cmake/ConvenienceLibrary.cmake | 15 cmake/FindDirectX.cmake | 497 cmake/FindSNAPPY.cmake | 13 cmake/Findprocps.cmake | 16 cmake/InstallPDB.cmake | 17 cmake/toolchain/android.toolchain.cmake | 391 common/formatter.hpp | 225 common/highlight.cpp | 324 common/highlight.hpp | 86 common/os.hpp | 27 common/os_backtrace.hpp | 5 common/os_binary.hpp | 4 common/os_dl.hpp | 4 common/os_memory.hpp | 23 common/os_posix.cpp | 111 common/os_process.hpp | 4 common/os_string.hpp | 6 common/os_thread.hpp | 198 common/os_time.hpp | 4 common/os_version.hpp | 61 common/os_win32.cpp | 88 common/trace_api.hpp | 5 common/trace_callset.hpp | 4 common/trace_dump.cpp | 67 common/trace_dump.hpp | 16 common/trace_fast_callset.hpp | 4 common/trace_file.hpp | 5 common/trace_file_snappy.cpp | 28 common/trace_file_zlib.cpp | 42 common/trace_format.hpp | 109 common/trace_loader.hpp | 4 common/trace_lookup.hpp | 4 common/trace_model.cpp | 95 common/trace_model.hpp | 31 common/trace_option.cpp | 9 common/trace_option.hpp | 7 common/trace_parser.cpp | 28 common/trace_parser.hpp | 7 common/trace_parser_flags.cpp | 85 common/trace_profiler.cpp | 1 common/trace_profiler.hpp | 4 common/trace_writer.cpp | 32 common/trace_writer.hpp | 5 common/trace_writer_local.cpp | 51 common/trace_writer_local.hpp | 6 common/trace_writer_model.cpp | 4 common/ubjson.hpp | 111 dispatch/.gitignore | 1 dispatch/CMakeLists.txt | 36 dispatch/compat.h | 23 dispatch/d2dimports.hpp | 4 dispatch/d3d10_1imports.hpp | 48 dispatch/d3d10imports.hpp | 9 dispatch/d3d11imports.hpp | 6 dispatch/d3d8imports.hpp | 4 dispatch/d3d9imports.hpp | 4 dispatch/d3derr.hpp | 43 dispatch/d3dimports.hpp | 57 dispatch/dispatch.py | 73 dispatch/dlopen.hpp | 4 dispatch/dxgiint.h | 25 dispatch/eglimports.hpp | 4 dispatch/glimports.hpp | 59 dispatch/glproc.py | 152 dispatch/glproc_egl.cpp | 27 dispatch/glproc_gl.cpp | 57 docs/BUGS.markdown | 215 docs/Dalvik.markdown | 52 docs/FORMAT.markdown | 128 docs/HACKING.markdown | 244 docs/INSTALL.markdown | 174 docs/NEWS.markdown | 100 docs/TODO.markdown | 1 docs/USAGE.markdown | 551 docs/VMWX_map_buffer_debug.txt | 116 gui/.gitignore | 3 gui/CMakeLists.txt | 80 gui/androiddevicedialog.cpp | 556 gui/androiddevicedialog.h | 65 gui/androidfiledialog.cpp | 279 gui/androidfiledialog.h | 45 gui/androidretracer.cpp | 326 gui/androidretracer.h | 33 gui/androidutils.cpp | 185 gui/androidutils.h | 71 gui/apicalldelegate.cpp | 18 gui/apicalldelegate.h | 5 gui/apisurface.cpp | 17 gui/apisurface.h | 14 gui/apitrace.cpp | 106 gui/apitrace.h | 24 gui/apitracecall.cpp | 258 gui/apitracecall.h | 47 gui/apitracefilter.cpp | 17 gui/apitracefilter.h | 5 gui/apitracemodel.cpp | 1 gui/apitracemodel.h | 5 gui/argumentseditor.h | 5 gui/calldurationgraph.h | 4 gui/glsledit.cpp | 2 gui/graphing/frameaxiswidget.h | 5 gui/graphing/graphaxiswidget.h | 5 gui/graphing/graphing.h | 5 gui/graphing/graphlabelwidget.h | 5 gui/graphing/graphview.h | 5 gui/graphing/graphwidget.h | 5 gui/graphing/heatmapverticalaxiswidget.h | 5 gui/graphing/heatmapview.h | 5 gui/graphing/histogramview.h | 5 gui/graphing/timeaxiswidget.h | 5 gui/imageviewer.cpp | 8 gui/imageviewer.h | 9 gui/jumpwidget.h | 5 gui/main.cpp | 5 gui/mainwindow.cpp | 392 gui/mainwindow.h | 24 gui/pixelwidget.h | 6 gui/profiledialog.cpp | 2 gui/profiledialog.h | 5 gui/profileheatmap.h | 13 gui/profiletablemodel.h | 4 gui/profiling.h | 5 gui/qapitrace.qrc | 46 gui/qubjson.cpp | 298 gui/qubjson.h | 34 gui/qubjson_test.cpp | 157 gui/resources/android-setup.png |binary gui/resources/android.png |binary gui/resources/glreference-man.sh | 10 gui/resources/glreference-registry.sh | 6 gui/resources/glreference.tsv | 6498 +++++----- gui/retracer.cpp | 183 gui/retracer.h | 22 gui/saverthread.cpp | 11 gui/saverthread.h | 6 gui/searchwidget.h | 5 gui/settingsdialog.cpp | 60 gui/settingsdialog.h | 11 gui/shaderssourcewidget.h | 5 gui/thumbnail.h | 5 gui/tracedialog.h | 5 gui/traceloader.cpp | 296 gui/traceloader.h | 34 gui/traceprocess.h | 5 gui/trimprocess.h | 6 gui/ui/androiddevicedialog.ui | 132 gui/ui/androidfiledialog.ui | 149 gui/ui/imageviewer.ui | 18 gui/ui/mainwindow.ui | 133 gui/ui/profilereplaydialog.ui | 12 gui/ui/settings.ui | 136 gui/vertexdatainterpreter.h | 5 helpers/CMakeLists.txt | 18 helpers/com_ptr.hpp | 87 helpers/d3d10size.hpp | 44 helpers/d3d11size.hpp | 44 helpers/d3d7size.hpp | 105 helpers/d3d8size.hpp | 4 helpers/d3d9size.hpp | 4 helpers/d3dcommonsize.hpp | 4 helpers/d3dshader.cpp | 4 helpers/d3dshader.hpp | 4 helpers/dxgisize.hpp | 4 helpers/eglsize.hpp | 5 helpers/glprofile.cpp | 325 helpers/glprofile.hpp | 143 helpers/glsize.hpp | 245 image/image.hpp | 13 image/image_md5.cpp | 6 image/image_png.cpp | 75 image/image_pnm.cpp | 11 inject/CMakeLists.txt | 11 inject/inject.h | 112 inject/injectee.cpp | 974 + inject/injector.cpp | 500 retrace/.gitignore | 2 retrace/CMakeLists.txt | 284 retrace/android/AndroidManifest.xml | 23 retrace/android/build.gradle | 46 retrace/android/java/apitrace/github/io/eglretrace/AbstractServer.java | 31 retrace/android/java/apitrace/github/io/eglretrace/QtCreatorDebugger.java | 242 retrace/android/java/apitrace/github/io/eglretrace/RetraceActivity.java | 114 retrace/android/java/apitrace/github/io/eglretrace/Servers.java | 54 retrace/android/local.properties.in | 7 retrace/android/res/drawable-hdpi/ic_launcher.png |binary retrace/android/res/drawable-mdpi/ic_launcher.png |binary retrace/android/res/drawable-xhdpi/ic_launcher.png |binary retrace/android/res/drawable-xxhdpi/ic_launcher.png |binary retrace/android/res/values/strings.xml | 4 retrace/d3d10state.cpp | 110 retrace/d3d10state.hpp | 89 retrace/d3d10state_images.cpp | 373 retrace/d3d11state.cpp | 137 retrace/d3d11state.hpp | 47 retrace/d3d11state_images.cpp | 435 retrace/d3d7state.cpp | 62 retrace/d3d7state_images.cpp | 216 retrace/d3d8state.cpp | 53 retrace/d3d8state_images.cpp | 231 retrace/d3d9retrace.py | 74 retrace/d3d9state.cpp | 52 retrace/d3d9state.hpp | 57 retrace/d3d9state_formats.cpp | 259 retrace/d3d9state_images.cpp | 191 retrace/d3dretrace.hpp | 18 retrace/d3dretrace_dxgi.hpp | 210 retrace/d3dretrace_dxgi_priv.cpp | 283 retrace/d3dretrace_main.cpp | 3 retrace/d3dstate.hpp | 70 retrace/ddrawretrace.py | 136 retrace/dllretrace.py | 1 retrace/dxgiretrace.py | 303 retrace/dxgistate.cpp | 348 retrace/dxgistate.hpp | 11 retrace/dxgistate_so.hpp | 116 retrace/dxgistate_so.py | 275 retrace/glretrace.hpp | 21 retrace/glretrace.py | 405 retrace/glretrace_cgl.cpp | 165 retrace/glretrace_egl.cpp | 102 retrace/glretrace_glx.cpp | 87 retrace/glretrace_main.cpp | 308 retrace/glretrace_wgl.cpp | 201 retrace/glretrace_ws.cpp | 84 retrace/glstate.cpp | 417 retrace/glstate.hpp | 12 retrace/glstate_formats.cpp | 662 + retrace/glstate_images.cpp | 667 - retrace/glstate_internal.hpp | 150 retrace/glstate_params.py | 369 retrace/glstate_shaders.cpp | 730 - retrace/glws.cpp | 55 retrace/glws.hpp | 37 retrace/glws_cocoa.mm | 42 retrace/glws_egl_android.cpp | 723 + retrace/glws_egl_xlib.cpp | 408 retrace/glws_glx.cpp | 340 retrace/glws_waffle.cpp | 90 retrace/glws_wgl.cpp | 197 retrace/glws_xlib.cpp | 245 retrace/glws_xlib.hpp | 69 retrace/json.cpp | 39 retrace/json.hpp | 49 retrace/retrace.cpp | 42 retrace/retrace.hpp | 49 retrace/retrace.py | 109 retrace/retrace_main.cpp | 149 retrace/retrace_stdc.cpp | 30 retrace/retrace_swizzle.cpp | 87 retrace/retrace_swizzle.hpp | 15 retrace/scoped_allocator.hpp | 9 retrace/state_writer.cpp | 81 retrace/state_writer.hpp | 182 retrace/state_writer_json.cpp | 126 retrace/state_writer_ubjson.cpp | 220 scripts/convert.py | 161 scripts/highlight.py | 4 scripts/jsondiff.py | 20 scripts/jsonextractimages.py | 21 scripts/retracediff.py | 1 scripts/tracediff.py | 87 scripts/unpickle.py | 57 specs/cglapi.py | 49 specs/d2d1.py | 5 specs/d3d.py | 116 specs/d3d10.py | 158 specs/d3d10_1.py | 119 specs/d3d10misc.py | 55 specs/d3d10sdklayers.py | 11 specs/d3d11.py | 369 specs/d3d11_1.py | 177 specs/d3d11sdklayers.py | 8 specs/d3d11shader.py | 186 specs/d3d8.py | 16 specs/d3d8types.py | 2 specs/d3d9.py | 33 specs/d3d9types.py | 2 specs/d3dcommon.py | 1 specs/d3dtypes.py | 4 specs/ddraw.py | 567 specs/dxgi.py | 584 specs/dxgi1_2.py | 52 specs/dxgiformat.py | 132 specs/dxgitype.py | 115 specs/eglapi.py | 40 specs/eglenum.py | 166 specs/glapi.py | 4217 +++--- specs/glesapi.py | 261 specs/glparams.py | 373 specs/gltypes.py | 8 specs/glxapi.py | 488 specs/scripts/.gitignore | 6 specs/scripts/Makefile | 46 specs/scripts/README.markdown | 8 specs/scripts/c2api.py | 442 specs/scripts/cdecl.py | 442 specs/scripts/eglenum.sh | 3 specs/scripts/glspec.py | 293 specs/scripts/gltxt.py | 244 specs/scripts/sort.sh | 2 specs/scripts/spec2api.py | 293 specs/scripts/txt2api.py | 244 specs/scripts/wglenum.sh | 5 specs/scripts/xml2api.py | 197 specs/scripts/xml2enum.py | 65 specs/scripts/xml2glparams.py | 43 specs/stdapi.py | 28 specs/wglapi.py | 84 specs/wglenum.py | 13 specs/winapi.py | 50 thirdparty/khronos/EGL/egl.h | 562 thirdparty/khronos/EGL/eglext.h | 292 thirdparty/khronos/EGL/eglplatform.h | 4 thirdparty/khronos/GL/glext.h | 1035 + thirdparty/khronos/GL/glxext.h | 102 thirdparty/khronos/GL/wglext.h | 13 thirdparty/khronos/GLES2/gl2.h | 154 thirdparty/khronos/GLES2/gl2ext.h | 1334 ++ thirdparty/khronos/Makefile | 14 thirdparty/snappy/CMakeLists.txt | 11 thirdparty/snappy/COPYING | 26 thirdparty/snappy/ChangeLog | 699 + thirdparty/snappy/NEWS | 39 thirdparty/snappy/config.h | 68 thirdparty/snappy/framing_format.txt | 35 thirdparty/snappy/snappy-c.h | 2 thirdparty/snappy/snappy-internal.h | 4 thirdparty/snappy/snappy-stubs-internal.h | 84 thirdparty/snappy/snappy-stubs-public.h | 17 thirdparty/snappy/snappy-stubs-public.h.in | 13 thirdparty/snappy/snappy-test.cc | 50 thirdparty/snappy/snappy-test.h | 99 thirdparty/snappy/snappy.cc | 347 thirdparty/snappy/snappy.h | 47 thirdparty/snappy/snappy_unittest.cc | 270 wrappers/.gitignore | 1 wrappers/CMakeLists.txt | 268 wrappers/assert.cpp | 65 wrappers/cgltrace.py | 24 wrappers/config.cpp | 448 wrappers/config.hpp | 74 wrappers/d2d1.def | 10 wrappers/d2d1trace.def | 8 wrappers/d3d10.def | 31 wrappers/d3d10_1.def | 32 wrappers/d3d10stubs.cpp | 522 wrappers/d3d11.def | 44 wrappers/d3d11stubs.cpp | 121 wrappers/d3d8trace.py | 2 wrappers/d3d9shader.hpp | 4 wrappers/d3d9trace.py | 54 wrappers/d3dcommonshader.hpp | 4 wrappers/d3dkmtstubs.cpp | 713 - wrappers/ddraw.def | 2 wrappers/ddrawtrace.py | 34 wrappers/dlltrace.py | 3 wrappers/dlsym.cpp | 79 wrappers/dwrite.def | 4 wrappers/dwritetrace.cpp | 6 wrappers/dxgi.def | 47 wrappers/dxgistubs.cpp | 114 wrappers/dxgitrace.def | 16 wrappers/dxgitrace.py | 73 wrappers/egltrace.py | 53 wrappers/egltrace.version | 10 wrappers/glcaps.cpp | 117 wrappers/gltrace.hpp | 23 wrappers/gltrace.py | 474 wrappers/gltrace_state.cpp | 9 wrappers/glxtrace.py | 2 wrappers/glxtrace.version | 9 wrappers/trace.py | 264 wrappers/wgltrace.py | 29 399 files changed, 35506 insertions(+), 18490 deletions(-)
New commits: commit 62ad71c6b6f770cd4ecc96f3a842cbf63c8bdc6c Author: Seth Berrier <[email protected]> Date: Fri Jun 26 07:20:04 2015 +0100 glretrace: Don't force GPU durations to zero. Fixes #359. diff --git a/common/trace_profiler.cpp b/common/trace_profiler.cpp index b765340..65c91aa 100644 --- a/common/trace_profiler.cpp +++ b/common/trace_profiler.cpp @@ -116,7 +116,6 @@ void Profiler::addCall(unsigned no, gpuStart -= baseGpuTime; } else { gpuStart = 0; - gpuDuration = 0; } if (cpuTimes && cpuStart) { commit 0a749b6475889d1f7db8da4385c77aadfe5b06d5 Author: Jose Fonseca <[email protected]> Date: Thu Jun 25 15:52:05 2015 +0100 glretrace: Workaround unusable GL_TIMESTAMP on Mac. Fixes #359. diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp index b02864f..ddb647e 100755 --- a/retrace/glretrace_main.cpp +++ b/retrace/glretrace_main.cpp @@ -374,6 +374,12 @@ initContext() { supportsDebugOutput = currentContext->hasExtension("GL_ARB_debug_output"); supportsARBShaderObjects = currentContext->hasExtension("GL_ARB_shader_objects"); +#ifdef __APPLE__ + // GL_TIMESTAMP doesn't work on Apple. GL_TIME_ELAPSED still does however. + // http://lists.apple.com/archives/mac-opengl/2014/Nov/threads.html#00001 + supportsTimestamp = false; +#endif + /* Check for timer query support */ if (retrace::profilingGpuTimes) { if (!supportsTimestamp && !supportsElapsed) { commit 04036909c0b0ffe0f49b1127e9d3693b4431eca7 Author: Jose Fonseca <[email protected]> Date: Thu Jun 25 15:51:04 2015 +0100 specs: Add type info for GL_TIMESTAMP. diff --git a/specs/glparams.py b/specs/glparams.py index 4636083..ad48a83 100644 --- a/specs/glparams.py +++ b/specs/glparams.py @@ -2802,7 +2802,7 @@ parameters = [ ("glGet", I, 1, "GL_TRANSFORM_FEEDBACK_BINDING"), # 0x8E25 ("", X, 1, "GL_FRAME_NV"), # 0x8E26 ("", X, 1, "GL_FIELDS_NV"), # 0x8E27 - ("", X, 1, "GL_TIMESTAMP"), # 0x8E28 + ("_glGet", I64, 1, "GL_TIMESTAMP"), # 0x8E28 ("", X, 1, "GL_NUM_FILL_STREAMS_NV"), # 0x8E29 ("", X, 1, "GL_PRESENT_TIME_NV"), # 0x8E2A ("", X, 1, "GL_PRESENT_DURATION_NV"), # 0x8E2B commit 5cd0ac50972bc8be658bb5315ff191afccb65aea Author: Jose Fonseca <[email protected]> Date: Thu Jun 25 14:36:10 2015 +0100 glretrace: Improve GL_ARB_timer_query support detection. Was part of core in GL_ARB_timer_query. diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp index 48c214a..b02864f 100755 --- a/retrace/glretrace_main.cpp +++ b/retrace/glretrace_main.cpp @@ -367,7 +367,8 @@ initContext() { } /* Ensure we have adequate extension support */ - supportsTimestamp = currentContext->hasExtension("GL_ARB_timer_query"); + supportsTimestamp = currentProfile.versionGreaterOrEqual(glprofile::API_GL, 3, 3) || + currentContext->hasExtension("GL_ARB_timer_query"); supportsElapsed = currentContext->hasExtension("GL_EXT_timer_query") || supportsTimestamp; supportsOcclusion = currentProfile.versionGreaterOrEqual(glprofile::API_GL, 1, 5); supportsDebugOutput = currentContext->hasExtension("GL_ARB_debug_output"); commit 1b685b0bb3a33b7b9eac254b4c4172903ef2eb38 Author: Jose Fonseca <[email protected]> Date: Wed Jun 17 21:57:41 2015 +0100 common: Use GetModuleHandle to detect WINE. Simpler and safer. diff --git a/common/highlight.cpp b/common/highlight.cpp index 6a1e783..334ba57 100644 --- a/common/highlight.cpp +++ b/common/highlight.cpp @@ -254,10 +254,9 @@ haveAnsi(void) } // http://wiki.winehq.org/DeveloperFaq#detect-wine - HMODULE hNtDll = LoadLibraryA("ntdll"); + HMODULE hNtDll = GetModuleHandleA("ntdll"); if (hNtDll) { result = GetProcAddress(hNtDll, "wine_get_version") != NULL; - FreeLibrary(hNtDll); } checked = true; commit 1d46c903de4562a9b24a602ac7b6d3ef281e28d6 Author: Jose Fonseca <[email protected]> Date: Tue Jun 16 15:51:53 2015 +0100 retrace: Remove duplicate "warning: " from warning message. diff --git a/retrace/retrace_swizzle.cpp b/retrace/retrace_swizzle.cpp index 1a3544f..ce89276 100644 --- a/retrace/retrace_swizzle.cpp +++ b/retrace/retrace_swizzle.cpp @@ -133,7 +133,7 @@ addRegion(trace::Call &call, unsigned long long address, void *buffer, unsigned regionMap.erase(start, stop); } else { for (RegionMap::iterator it = start; it != stop; ++it) { - warning(call) << "warning: " << std::hex << + warning(call) << std::hex << "region 0x" << address << "-0x" << (address + size) << " " "intersects existing region 0x" << it->first << "-0x" << (it->first + it->second.size) << "\n" << std::dec; assert(intersects(it, address, size)); commit 53ea8108dd795a58b3a147e56a92afd21dc145f1 Author: Jose Fonseca <[email protected]> Date: Thu Jun 25 14:28:09 2015 +0100 glretrace: Fix occlusion query support detection. GL_ARB_occlusion_query was made part of core OpenGL 1.5. Furthermore we don't use the *ARB entry-points, so we really rely on the core support. Futhermore, on Mac OS, core 3.2+ profiles do not list core extensions, so we were wrongly assuming it was missing. Fixes #358. diff --git a/helpers/glprofile.hpp b/helpers/glprofile.hpp index be2a111..397777d 100644 --- a/helpers/glprofile.hpp +++ b/helpers/glprofile.hpp @@ -84,6 +84,11 @@ struct Profile { (major == refMajor && minor >= refMinor); } + inline bool + versionGreaterOrEqual(Api refApi, unsigned refMajor, unsigned refMinor) const { + return api == refApi && versionGreaterOrEqual(refMajor, refMinor); + } + bool matches(const Profile expected) const; diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp index 599ebed..48c214a 100755 --- a/retrace/glretrace_main.cpp +++ b/retrace/glretrace_main.cpp @@ -369,7 +369,7 @@ initContext() { /* Ensure we have adequate extension support */ supportsTimestamp = currentContext->hasExtension("GL_ARB_timer_query"); supportsElapsed = currentContext->hasExtension("GL_EXT_timer_query") || supportsTimestamp; - supportsOcclusion = currentContext->hasExtension("GL_ARB_occlusion_query"); + supportsOcclusion = currentProfile.versionGreaterOrEqual(glprofile::API_GL, 1, 5); supportsDebugOutput = currentContext->hasExtension("GL_ARB_debug_output"); supportsARBShaderObjects = currentContext->hasExtension("GL_ARB_shader_objects"); commit d1f3582d14a1a496c248262ed873de34ab47bb58 Author: Jose Fonseca <[email protected]> Date: Thu Jun 25 13:31:09 2015 +0100 glstate: Support more texture buffer formats. diff --git a/retrace/glstate_formats.cpp b/retrace/glstate_formats.cpp index b784b8c..b07bd68 100644 --- a/retrace/glstate_formats.cpp +++ b/retrace/glstate_formats.cpp @@ -29,6 +29,8 @@ #include <assert.h> #include <iostream> +#include <limits> +#include <type_traits> #include "glsize.hpp" #include "glstate.hpp" @@ -65,6 +67,7 @@ formatToString(GLenum internalFormat) { static const InternalFormatDesc internalFormatDescs[] = { + // GLenum internalFormat, GLenum format, GLenum type, GLenum readType // Unsized UNORM { 1, GL_RED, GL_NONE, GL_UNSIGNED_BYTE }, @@ -416,4 +419,244 @@ getImageFormat(GLenum format, GLenum type, } +// Macros for describing arbitrary swizzles + +#define SWIZZLE_X 0 +#define SWIZZLE_Y 1 +#define SWIZZLE_Z 2 +#define SWIZZLE_W 3 +#define SWIZZLE_0 4 +#define SWIZZLE_1 5 +#define SWIZZLE_COUNT 6 + +#define SWIZZLE_BITS 4 +#define SWIZZLE_MASK ((1 << SWIZZLE_BITS) - 1) + +#define SWIZZLE(x, y, z, w) \ + (((SWIZZLE_##x) << (SWIZZLE_BITS*0)) | \ + ((SWIZZLE_##y) << (SWIZZLE_BITS*1)) | \ + ((SWIZZLE_##z) << (SWIZZLE_BITS*2)) | \ + ((SWIZZLE_##w) << (SWIZZLE_BITS*3))) + +#define SWIZZLE_RGBA SWIZZLE(X,Y,Z,W) +#define SWIZZLE_RGB SWIZZLE(X,Y,Z,1) +#define SWIZZLE_RG SWIZZLE(X,Y,0,1) +#define SWIZZLE_R SWIZZLE(X,0,0,1) +#define SWIZZLE_LA SWIZZLE(X,X,X,Y) +#define SWIZZLE_L SWIZZLE(X,X,X,1) +#define SWIZZLE_A SWIZZLE(0,0,0,X) +#define SWIZZLE_I SWIZZLE(X,X,X,X) + +#define SWIZZLE_EXTRACT(swizzle, channel) \ + ((swizzle) >> (SWIZZLE_BITS * (channel)) & SWIZZLE_MASK) + + +// Template that can describe all regular array-based pixel formats +template< typename Type, unsigned components, bool normalized, uint16_t swizzle > +class PixelTemplate : public PixelFormat +{ +protected: + + static_assert( 1 <= components && components <= 4, "invalid number of components" ); + + static const unsigned swizzle_r = SWIZZLE_EXTRACT(swizzle, 0); + static const unsigned swizzle_g = SWIZZLE_EXTRACT(swizzle, 1); + static const unsigned swizzle_b = SWIZZLE_EXTRACT(swizzle, 2); + static const unsigned swizzle_a = SWIZZLE_EXTRACT(swizzle, 3); + + static_assert( swizzle_r < components || swizzle_r == SWIZZLE_0 || swizzle_r == SWIZZLE_1, "invalid R swizzle" ); + static_assert( swizzle_g < components || swizzle_g == SWIZZLE_0 || swizzle_g == SWIZZLE_1, "invalid G swizzle" ); + static_assert( swizzle_b < components || swizzle_b == SWIZZLE_0 || swizzle_b == SWIZZLE_1, "invalid B swizzle" ); + static_assert( swizzle_a < components || swizzle_a == SWIZZLE_0 || swizzle_a == SWIZZLE_1, "invalid A swizzle" ); + + // We must use double precision intermediate values when normalizing 32bits integers. + typedef typename std::conditional< normalized && sizeof(Type) >= 4 , double , float >::type Scale; + + // Scale normalized types + template<typename T = void> + static inline Scale + scale(Scale value, typename std::enable_if<normalized, T>::type* = 0) + { + static_assert( normalized, "should only be instantiated for normalized types" ); +#ifndef _MSC_VER + static constexpr Type typeMax = std::numeric_limits<Type>::max(); + static_assert( static_cast<Type>(static_cast<Scale>(typeMax)) == typeMax, + "intermediate type cannot represent maximum value without loss of precission" ); + static constexpr Scale scaleFactor = Scale(1) / Scale(typeMax); + static_assert( Scale(typeMax) * scaleFactor == Scale(1), "cannot represent unity" ); + static_assert( Scale(0) * scaleFactor == Scale(0), "cannot represent zero" ); +#else + // XXX: MSCV doesn't support constexpr yet + static const Type typeMax = std::numeric_limits<Type>::max(); + assert( static_cast<Type>(static_cast<Scale>(typeMax)) == typeMax ); + static const Scale scaleFactor = Scale(1) / Scale(typeMax); + assert( Scale(typeMax) * scaleFactor == Scale(1) ); + assert( Scale(0) * scaleFactor == Scale(0) ); +#endif + return value * scaleFactor; + } + + // No-op for unormalized types + template<typename T = void> + static inline Scale + scale(Scale value, typename std::enable_if<!normalized, T>::type* = 0) + { + static_assert( !normalized, "should only be instantiated for non-normalized types" ); + return value; + } + + // Unpack a single pixel + static inline void + unpackPixel(const Type *inPixel, float outPixel[4]) + { + float scaledComponents[SWIZZLE_COUNT]; + for (unsigned component = 0; component < components; ++component) { + Scale scaledComponent = scale(static_cast<Scale>(inPixel[component])); + scaledComponents[component] = static_cast<float>(scaledComponent); + } + scaledComponents[SWIZZLE_0] = 0.0f; + scaledComponents[SWIZZLE_1] = 1.0f; + + outPixel[0] = scaledComponents[swizzle_r]; + outPixel[1] = scaledComponents[swizzle_g]; + outPixel[2] = scaledComponents[swizzle_b]; + outPixel[3] = scaledComponents[swizzle_a]; + } + +public: + + inline + PixelTemplate(void) { + } + + size_t + size(void) const { + return sizeof(Type) * components; + } + + void + unpackSpan(const uint8_t *inSpan, float *outSpan, unsigned width) const + { + const Type *inPixel = reinterpret_cast<const Type *>(inSpan); + + for (unsigned x = 0; x < width; ++x) { + unpackPixel(inPixel, outSpan); + inPixel += components; + outSpan += 4; + } + } +}; + + +const PixelFormat * +getPixelFormat(GLenum internalFormat) +{ + static const bool Y = true; + static const bool N = false; + +#define CASE(internalFormat, type, components, norm, swizzle) \ + case GL_##internalFormat: \ + { \ + static const PixelTemplate< GL##type, components, norm, SWIZZLE_##swizzle > pixel; \ + return &pixel; \ + } + + switch (internalFormat) { + + CASE(ALPHA8, ubyte, 1, Y, A); + CASE(ALPHA16, ushort, 1, Y, A); + CASE(ALPHA16F_ARB, half, 1, N, A); + CASE(ALPHA32F_ARB, float, 1, N, A); + CASE(ALPHA8I_EXT, byte, 1, N, A); + CASE(ALPHA16I_EXT, short, 1, N, A); + CASE(ALPHA32I_EXT, int, 1, N, A); + CASE(ALPHA8UI_EXT, ubyte, 1, N, A); + CASE(ALPHA16UI_EXT, ushort, 1, N, A); + CASE(ALPHA32UI_EXT, uint, 1, N, A); + + CASE(LUMINANCE8, ubyte, 1, Y, L); + CASE(LUMINANCE16, ushort, 1, Y, L); + CASE(LUMINANCE16F_ARB, half, 1, N, L); + CASE(LUMINANCE32F_ARB, float, 1, N, L); + CASE(LUMINANCE8I_EXT, byte, 1, N, L); + CASE(LUMINANCE16I_EXT, short, 1, N, L); + CASE(LUMINANCE32I_EXT, int, 1, N, L); + CASE(LUMINANCE8UI_EXT, ubyte, 1, N, L); + CASE(LUMINANCE16UI_EXT, ushort, 1, N, L); + CASE(LUMINANCE32UI_EXT, uint, 1, N, L); + + CASE(LUMINANCE8_ALPHA8, ubyte, 2, Y, LA); + CASE(LUMINANCE16_ALPHA16, ushort, 2, Y, LA); + CASE(LUMINANCE_ALPHA16F_ARB, half, 2, N, LA); + CASE(LUMINANCE_ALPHA32F_ARB, float, 2, N, LA); + CASE(LUMINANCE_ALPHA8I_EXT, byte, 2, N, LA); + CASE(LUMINANCE_ALPHA16I_EXT, short, 2, N, LA); + CASE(LUMINANCE_ALPHA32I_EXT, int, 2, N, LA); + CASE(LUMINANCE_ALPHA8UI_EXT, ubyte, 2, N, LA); + CASE(LUMINANCE_ALPHA16UI_EXT, ushort, 2, N, LA); + CASE(LUMINANCE_ALPHA32UI_EXT, uint, 2, N, LA); + + CASE(INTENSITY8, ubyte, 1, Y, I); + CASE(INTENSITY16, ushort, 1, Y, I); + CASE(INTENSITY16F_ARB, half, 1, N, I); + CASE(INTENSITY32F_ARB, float, 1, N, I); + CASE(INTENSITY8I_EXT, byte, 1, N, I); + CASE(INTENSITY16I_EXT, short, 1, N, I); + CASE(INTENSITY32I_EXT, int, 1, N, I); + CASE(INTENSITY8UI_EXT, ubyte, 1, N, I); + CASE(INTENSITY16UI_EXT, ushort, 1, N, I); + CASE(INTENSITY32UI_EXT, uint, 1, N, I); + + CASE(RGBA8, ubyte, 4, Y, RGBA); + CASE(RGBA16, ushort, 4, Y, RGBA); + CASE(RGBA16F, half, 4, N, RGBA); + CASE(RGBA32F, float, 4, N, RGBA); + CASE(RGBA8I, byte, 4, N, RGBA); + CASE(RGBA16I, short, 4, N, RGBA); + CASE(RGBA32I, int, 4, N, RGBA); + CASE(RGBA8UI, ubyte, 4, N, RGBA); + CASE(RGBA16UI, ushort, 4, N, RGBA); + CASE(RGBA32UI, uint, 4, N, RGBA); + + CASE(RGB8, ubyte, 3, Y, RGB); + CASE(RGB16, ushort, 3, Y, RGB); + CASE(RGB16F, half, 3, N, RGB); + CASE(RGB32F, float, 3, N, RGB); + CASE(RGB8I, byte, 3, N, RGB); + CASE(RGB16I, short, 3, N, RGB); + CASE(RGB32I, int, 3, N, RGB); + CASE(RGB8UI, ubyte, 3, N, RGB); + CASE(RGB16UI, ushort, 3, N, RGB); + CASE(RGB32UI, uint, 3, N, RGB); + + CASE(RG8, ubyte, 2, Y, RG); + CASE(RG16, ushort, 2, Y, RG); + CASE(RG16F, half, 2, N, RG); + CASE(RG32F, float, 2, N, RG); + CASE(RG8I, byte, 2, N, RG); + CASE(RG16I, short, 2, N, RG); + CASE(RG32I, int, 2, N, RG); + CASE(RG8UI, ubyte, 2, N, RG); + CASE(RG16UI, ushort, 2, N, RG); + CASE(RG32UI, uint, 2, N, RG); + + CASE(R8, ubyte, 1, Y, R); + CASE(R16, ushort, 1, Y, R); + CASE(R16F, half, 1, N, R); + CASE(R32F, float, 1, N, R); + CASE(R8I, byte, 1, N, R); + CASE(R16I, short, 1, N, R); + CASE(R32I, int, 1, N, R); + CASE(R8UI, ubyte, 1, N, R); + CASE(R16UI, ushort, 1, N, R); + CASE(R32UI, uint, 1, N, R); + + default: + return nullptr; + } + +#undef CASE +} + + } /* namespace glstate */ diff --git a/retrace/glstate_images.cpp b/retrace/glstate_images.cpp index 19ff35f..c111efa 100644 --- a/retrace/glstate_images.cpp +++ b/retrace/glstate_images.cpp @@ -441,15 +441,21 @@ dumpActiveTextureLevel(StateWriter &writer, Context &context, const InternalFormatDesc &formatDesc = getInternalFormatDesc(desc.internalFormat); - if (target == GL_TEXTURE_BUFFER && formatDesc.type != GL_UNSIGNED_BYTE) { - // FIXME: We rely on glGetTexImage to convert the pixels, but we can't use it with texture buffers. - std::cerr << "warning: unsupported texture buffer internal format " << formatToString(desc.internalFormat) << "\n"; - return; - } - GLenum format; GLenum type; - chooseReadBackFormat(formatDesc, format, type); + const PixelFormat *pixelFormat = nullptr; + + if (target == GL_TEXTURE_BUFFER) { + pixelFormat = getPixelFormat(desc.internalFormat); + if (!pixelFormat) { + std::cerr << "warning: unsupported texture buffer internal format " << formatToString(desc.internalFormat) << "\n"; + return; + } + format = GL_RGBA; + type = GL_FLOAT; + } else { + chooseReadBackFormat(formatDesc, format, type); + } writer.beginMember(label); @@ -473,7 +479,11 @@ dumpActiveTextureLevel(StateWriter &writer, Context &context, if (target == GL_TEXTURE_BUFFER) { assert(desc.height == 1); - assert(type == GL_UNSIGNED_BYTE); + assert(desc.depth == 1); + assert(pixelFormat); + assert(format == GL_RGBA); + assert(type == GL_FLOAT); + assert(image->bytesPerPixel == sizeof(float[4])); GLint buffer = 0; glGetIntegerv(GL_TEXTURE_BUFFER_DATA_STORE_BINDING, &buffer); @@ -483,7 +493,8 @@ dumpActiveTextureLevel(StateWriter &writer, Context &context, const GLvoid *map = bm.map(GL_TEXTURE_BUFFER, buffer); if (map) { - memcpy(image->pixels, map, image->width * image->bytesPerPixel); + pixelFormat->unpackSpan(static_cast<const uint8_t *>(map), + reinterpret_cast<float *>(image->pixels), image->width); } } else { if (context.ES) { diff --git a/retrace/glstate_internal.hpp b/retrace/glstate_internal.hpp index 18c7147..3302a81 100644 --- a/retrace/glstate_internal.hpp +++ b/retrace/glstate_internal.hpp @@ -26,6 +26,8 @@ #pragma once +#include <stdint.h> + #include "glimports.hpp" #include "glproc.hpp" #include "image.hpp" @@ -110,6 +112,26 @@ getImageFormat(GLenum format, GLenum type, GLuint &channels, image::ChannelType &channelType); +// Abstract base class for pixel format conversion +class PixelFormat +{ +public: + virtual ~PixelFormat() {} + + // Size in bytes + virtual size_t + size(void) const = 0; + + // Unpack a span of pixels + virtual void + unpackSpan(const uint8_t *inSpan, float *outSpan, unsigned width) const = 0; +}; + + +const PixelFormat * +getPixelFormat(GLenum internalFormat); + + /** * Helper class to temporarily bind a buffer to the specified target until * control leaves the declaration scope. commit 84eac2523370fab8f92beef21cf9f2743060c85e Author: Jose Fonseca <[email protected]> Date: Thu Jun 25 12:34:43 2015 +0100 d3dretrace: Dont retrace GetDC/ReleaseDC. diff --git a/specs/d3d9.py b/specs/d3d9.py index c98c7f2..2101514 100644 --- a/specs/d3d9.py +++ b/specs/d3d9.py @@ -363,8 +363,8 @@ IDirect3DSurface9.methods += [ StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3DSURFACE_DESC), "pDesc")], sideeffects=False), StdMethod(HRESULT, "LockRect", [Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]), StdMethod(HRESULT, "UnlockRect", []), - StdMethod(HRESULT, "GetDC", [Out(Pointer(HDC), "phdc")]), - StdMethod(HRESULT, "ReleaseDC", [(HDC, "hdc")]), + StdMethod(HRESULT, "GetDC", [Out(Pointer(HDC), "phdc")], sideeffects=False), + StdMethod(HRESULT, "ReleaseDC", [(HDC, "hdc")], sideeffects=False), ] IDirect3DVolume9.methods += [ commit 5642f6578ec8ebcc73e1b9aa3826d37010a5b7ce Author: Jose Fonseca <[email protected]> Date: Wed Jun 24 11:33:26 2015 +0100 cli/sed: Avoid strcpy. diff --git a/cli/cli_sed.cpp b/cli/cli_sed.cpp index 1ad035b..401b7a6 100644 --- a/cli/cli_sed.cpp +++ b/cli/cli_sed.cpp @@ -108,9 +108,10 @@ public: void visit(String *node) { if (!searchName.compare(node->value)) { + size_t len = replaceName.length() + 1; delete [] node->value; - char *str = new char [replaceName.length() + 1]; - strcpy(str, replaceName.c_str()); + char *str = new char [len]; + memcpy(str, replaceName.c_str(), len); node->value = str; } } commit 8b0807fc98700fdaf69ed880eab416e43194f219 Author: Jose Fonseca <[email protected]> Date: Wed Jun 24 11:29:01 2015 +0100

