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

update from latest upstream #6

Merged
merged 65 commits into from Mar 20, 2013
Merged

update from latest upstream #6

merged 65 commits into from Mar 20, 2013

Conversation

igor-c
Copy link
Owner

@igor-c igor-c commented Mar 20, 2013

No description provided.

Andy Chien and others added 30 commits November 20, 2012 14:32
PPAPI is an API which contains GLES2 calls. The Chrome plugin,
on the other hand, could be NaCl-based or Trusted (for Windows,
Linux and perhaps Mac). So, the API name (PPAPI in our case)
is somewhat orthogonal to the target platform.

See https://github.com/p3/regal/pull/30
Further logging refinements.
Redbook example programs.
Add the head version of GoogleTest (using
https://git.chromium.org/git/external/googletest.git), with a version
equivalent to Subversion change #625. Note that I've trimmed out some
parts of the tree that aren't directly related to building a working
library (such as their self-tests), but I preserved the special files in
the root directory of the project (such as LICENSE).

Modifies the Makefile to build "lib/libgtest.a" from the Google Test sources.

Adds a tests/ subdirectory for Regal tests. Adds a test_main.cpp file,
which will run all the tests, and contains a trivial test for
verification.

Modifies the Makefile to build and run "bin/RegalTests" from the
tests/ source code if "make tests" is run. The tests however are not
built/run by the "make all"
Conflicts:
	build/ppapi/vs2010/Regal/Regal.sln
	build/ppapi/vs2010/Regal/Regal.vcxproj
	build/ppapi/vs2010/Regal/Regallib.vcxproj
	build/ppapi/vs2010/Regal/Regalm.vcxproj
	build/ppapi/vs2010/Regal/Regalmlib.vcxproj
	include/GL/Regal.h
	src/regal/RegalContext.cpp
	src/regal/RegalContext.h
	src/regal/RegalDispatchLoader.cpp
	src/regal/RegalDispatchNacl.cpp
	src/regal/RegalDispatcher.cpp
	src/regal/RegalHttp.h
	src/regal/RegalInit.cpp
	src/regal/RegalInit.h
	src/regal/RegalLog.cpp
	src/regal/RegalThread.h
	src/regal/RegalTimer.h
	src/regal/RegalUtil.cpp
Add Google Test unit testing framework.
REGAL_SYS_FOO variables are always defined. (0 or 1)
Initialization refinement for EGL - EmuInit.py added.
Regal::Config support for EGL and GLX at runtime.
Complete list of extensions in Regal::ContextInfo
REGAL_LOG_ONCE for logging warnings and errors once only
Sampler object emulation refinements.
RegalSo optimizations.
Merged GLX/EGL and GL/GLES entry-point loading for Linux.  x86, x86_64 and ARM.
GLenum to string conversion refinements, prefer non-extension, ARB, KHR and so on.
GL spec database entries for maxSize of input parameters.  (vs output size)
A patch for issue #31.

Under an GLES2 API (and specifically Pepper implementation of GLES2),
calls to glTexSubImage2D may be required to use a type and format for
the new data that matches the underlying texture type/format, so that
the GLES2 implementation is a simple, straight copy of the data.

This means that in order for Regal to emulate the less strict OpenGL
interface, it must perform texture format conversions when calling a
GLES2 backend.

This patch adds such an emulation recipe, that:

1) Shadows the state of textures, so that Regal knows the underlying
formats, and
2) On a call to glTexSubImage2D, if the caller is passing something that
doesn't match the underlying texture format, Regal will handle the
conversion.

This patch makes a few assumptions that may need to be relaxed with
further changes:

* Only OpenGLES 2.0 compatible texture types and formats are supported.
  GL_BGRA and GL_UNSIGNED_BYTE_3_2_2 for example, while easy to add, are
  not. Other more general OpenGL formats could be added to, with a bit
  more work.
* As per the GLES2.x spec, only GL_UNPACK_ALIGNMENT is assumed to be
  relevant.
* To avoid a combinatorial explosion, all texture conversions are too
  and from a simple GL_RGBA, GL_UNSIGNED_BYTE intermedate format.
Logging refinements

Per-toolchain debug and release flags for Makefile build.

Regal sampler object refinements.

Logging refinements - REGAL_LOG_MAX_BYTES=n for limiiting raw bytes, REGAL_LOG_MAX_BYTES=0 to omit pointers.

Extend boost::print to support optional output.
Before this change Export.py only worked from project root.
This also adds error message when output dir is not set.
Because this is what it really is.
make export - Export.py command-line has changed.
Makefile defaults to MODE=release
Texture parameter logging improvements.
boost::string_list support for splitting glShaderSource string arrays, with optional delimiter
Optional logging of pointers - REGAL_LOG_POINTERS=1 by default
Optional logging of thread, per line of log output - REGAL_LOG_THREAD=0 by default
In Init::context, avoid assertion if thread was previously associated with the context
Optional writing to shader cache - REGAL_CACHE_SHADER_WRITE=1 by default in debug mode
Initial test coverage added for boost::string_list
Add makePath utility function for joining a directory and filename.
Move Regal::Thread dependency from RegalPrivate.h to RegalContext.h
Add jsonsl to src tree, for parsing JSON data.
Extend boost::print to support pad(width) operator for indentation.
Info logging for shader caching.
Logging enhancement for texture parameter.
shaderSourceStrings - to NUL-terminated string.
Build regaltest as part of all Makefile target.
RegalSo sRGB support for ES 2.0
Add support for masking the buffer bits used for MD5 hashing purposes
RegalSo fixes and optimizations.
Helper functions for pixel components and bytes per component.
1) A few places assumed REGAL_SYS_PPAPI meant Windows/MSVC when in fact
Pepper is a valid option on Mac and Linux as well.

2) Initialize maxVaryings to zero before calling GetIntegerv. Pepper
GLES GetIntegerv for better or worse asserts that the output destination
memory is initialized to zero or negative one, though I saw nothing in
the spec that indicates it is required.
nigels-com and others added 28 commits January 23, 2013 18:36
use std::swap_ranges for swapping arrays.
Make the dispatch table initializers available to regaltest.
White-list more GL functions into RegalDispatchGMock, for regaltest purposes.
freeglut tidy-up for possible upstreaming.
For X11/EGL mode, include additional X11 headers that would have come from GL/EGL.h
Extend clip plane enum support to GL_CLIP_PLANE6, GL_CLIP_PLANE7
Add category annotation for GL_VERSION_2_0 entry points
Extend RegalDispatchGMock to GL_VERSION_2_0, in addition to 1.0 and 1.1
…0 to disable.

Fixups for texture image size helpers.
DSA emulation fixes.
boost::print logging fix for quoting NULL c-strings.
boost::print logging fix for NULL arrays.
Add Push/PopClientAttribute emulation for Regal, allowing the full
OpenGL 4.3 compatability profile pixel and vertex array states to be
saved and restored.

These notes and the implementation are based on
glspec43.compatability.20120806.pdf, as well as
http://www.opengl.org/registry/specs/EXT/direct_state_access.txt

This is needed when running on top of a back-end which does not support it
(GLES2), when the caller is an more general OpenGL client.

Specifically, the state mentioned in Tables 23.4 - 23.8 identified as
"vertex array", and the state in Tables 23.34 and 23.35 identified as
"pixel-store" is what is saved and restored.

For the pixel store state, this was straightforward. For the vertex
array state, this was more involved than I initially expected, leading
to this rather large patch. Sorry.

I implemented this version with the following in mind:

  * The client state tracking should not constrain itself to the client
    state actually supported by the back-end. If the client for example
    calls glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE), we record and
    attempt to restore this change in state even if the back-end is
    GLES2 which does not support it. If the client never makes this
    call, then we never attempt to touch this state on restore.

    It is assumed that for GLES2 and other similarly restrictive
    back-ends that some other emulation layer will handle it as needed.

  * Primarily this change is about implementing emulated versions of
    glPushClientAttrib and glPopClientAttrib. All "global" client state
    is tracked. Note that some calls would set state inside a Vertex
    Array Object if one is bound, and this code ignores those calls
    since that goes beyond what was needed. Also, while it implements
    glGet for the purposes of constraining certain attribute count
    limits and other maximums, it does not otherwise implement any
    real functionality to get the shadowed client state.

  * Beyond the compatability profile specification, I only handled the
    Direct State Access extension, as there was already the RegalDsa
    module present to emulate it. I pass the calls through after
    shadowing the state, but in restoring state, I went and made the
    more stateful calls without using that extension.

  * I did my best to track the spec properly. There are a few corner
    cases I did not properly handle.

      1. This code does not know what buffers and vertex array objects,
         etc. are properly allocated. The specification calls for the
         interface to not allow an unallocated named object to be bound,
         which should mean that this shadowing interface should ignore
         the attempt.

      2. Between the glBegin() / glEnd() call pair, calls other than
         those to set single vertex attributes should fail. The
         specification calls out a limited set of functions which might
         not (10.8.5, after the errors box).

      3. I was uncertain what to do if a state saved on the stack
         contained a named object that was deleted. While I check the
         current state, and effectively unbind, I did not do so for the
         state stack. Some similar handling might need to be done for
         bound objects stored inside a Vertex Array Object.

As I neared the end of the work on this patch, I strongly felt that the
following should really be done further down the line:

  * With this change, Regal now has much redundancy in code that tracks
    client state. I was really tempted to help clean this up, but I
    don't feel like I have the time.

    I feel like the emulation layer should implement one or more modules
    to shadow OpenGL state, which should be all they do. I could see
    making them configurable so that for example if vertex array state
    was not needed, no attempt would be made to shadow it.

    Other modules can then "require" this layer to work. RegalPpca would
    then just implement the state stacks, and the Push/pop
    functionality.

    I'm hoping at least that you will find my implementation at least a
    good starting point for this unification. I checked it numerous
    times.

  * In working through this patch, I looked briefly at the code in
    RegalIff, RegalVao, and RegalPpc (the last of which is not
    apparently used, and appeared to be the closest to what I wanted to
    do in this patch). I used them to cross check my version, but I did
    not directly use them as I felt each of them was incomplete (not
    implementing all the interfaces, not consistently checking for bad
    parameters, ...)

    There are still some differences to call out, which should be
    resolved at part of the unification:

      1. RegalVao implements Vertex Array Objects assuming the back-end
         does not. If vertex array state were unified, it would still
         perform this function.
      2. RegalIff includes some code to handle the having only
         8 vertex attributes, and also maps the fixed-function
         attributes into generic attribute entries. The mapping seemed
         wrong, so I did not do it, but I'm sure the 8 vertex attribute
         restriction is important for some platform. Integrating the
         state tracking done by this module would also seem like the
         most work involved in a unification effort.
      3. RegalPpc implements state query functionality, which RegalPpca
         does not.
Refresh VC10 projects.
Resolve MS compilation warnings and errors.
Moving regal emulation objects into Regal::Emu namespace.
I neglected to properly track the array buffer binding per fixed vertex
array client state.

Add in the missing functionality, along with related tests to cover the
change.
In reviewing the spec tables for my vertex array state changes, I
realized that I had missed adding support for tracking
enabling/disabling GL_DEPTH_CLAMP as transform state in my change where
I added transform state tracking.

Add it in, with test coverage.
X11 window manager state logging support added.
Do not auto-detect REGAL_SYS_GLX if REGAL_SYS_X11=0.
GL api database corrections for GL_VERSION_x_y.
Extend GL database to list per-extension information
EmuFilter layer - selective ES 2.0 filtering
Increase the strictness of emulation regex matching - must be unique
Initial implementation of JSON output
Under a sequence like:

  // Render some geometry

  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glOrtho( /* for rendering a HUD/overlay in screen space */ )
  // Render the overlay
  glPopMatrix();

  // Render some more geometry

... I found that the glOrtho call was unexpectedly affecting the
rendering of subsequent geometry.

I traced it down to a issue in the Regal code, where the fixed function
emulation shader uniform state was not being invalidated when performing
the glPopMatrix, so it would go on using the incorrect matrix.

Note this also affected other matrix modes, not just GL_PROJECTION.

This patch is the one line fix needed to invalidate the state so the
proper matricies are loaded.

Sorry, I didn't feel like adding a whole new unit test file for a one
line change.
Initial REGAL_SYS_ES1, REGAL_SYS_ES2 and REGAL_SYS_GL for compile-time support for ES 1.x, ES 2.x or deskop back-end GL support.
Python is not a Java - no need to use classes where
they are not needed. The __main__ convention makes
it easier to locate entrypoints for experienced
Python users, and also allows to use Export.py as a
library.
Regal::Emu::So optimizations.
…dow-pos.

Extend RegalHelper helper::size::get to desktop enums.
Trim extraneous whitespace.
Add Regal::Break::Filter for debugger breakpoints on filtered functions.
Mac XCode project updates.
Windows VC10 project updates.
Improved Mac OS X force core context.
Add Error dispatch breakpoint to Regal::break scope.
Improved core context support.
Fixes:

  I had the bad luck of testing this change originally with a brightly
  colored abstract block game, and I didn't noticed that the red and
  blue channels were swapped. I tracked it down to a confusion on my
  part about the order of the packed components in each integer, and how
  it worked for bit-packed and non-bit-packed forms.

  This quick fix is to just swap around masks for the Red and Blue
  components for the packed-pixel types (such as
  GL_UNSIGNED_SHORT_5_6_5), and adjust the corresponding tests to go
  along with it.

  This looks inconsistent with the surrounding declarations, as the
  bit-packed forms say that red (or at least the first component) is in
  the highest bits, while the non-bit-packed forms seem to say that red
  is in the lowest bits. Both however are correct due to the way the
  values are read out of memory.

  I spent an extra day trying to make this consistent, and also
  properly handle endian swapping. However I got bogged down in the
  clean up, and I ran out of time to do it for now. I left some comments
  around it in the code, and I'll keep my work in progress patch, but I
  won't have time in the near future to do anything on it.

  Along the way, I also noticed that the intensity-alpha format
  specification was using the first byte for both values, instead of
  using the second byte for alpha as it was supposed to.

Cleanups:

  * I removed some dead declarations that I left behind before submitting.
    I had meant to take them out, and missed them.

  * I added some comments to document the RegalPixelConversions header.

  * Removed a TODO comment around using memcpy when dealing with
    conversions of <GL_RGBA, GL_UNSIGNED_BYTE> to/from the intermediate
    format. There is an opportunity to use a memcpy for some formats,
    but for the format I called out it may not be possible (depends on
    endian).
DXT1 and DXT5 via squishlib, disabled by default.
Per emulation layer force flag REGAL_FORCE_EMU_FOO for Regal::Config.
build/regal.inc for GNU make list of sources and headers.
Updated VC projects.
Extend RegalUtil.h to ensure that REGAL_NO_ASSERT, REGAL_NO_PNG, REGAL_NO_SQUISH, REGAL_NO_TLS are always defined - 0 or 1.
Update boost (subset) to 1.53.0 release.
Move zlib, libpng, GLU and GLUT source lists into build/foo.inc for Makefile build.
Move NACL_SDK_ROOT logic into config/Makefile.nacl
Makefile revamp - put libs in lib/$(SYSTEM) and binaries in bin/$(SYSTEM)
Add clobber target for wiping out all temps, libs and binaries
Fixups for core and compat profiles.
Refinements for Android ndk-build.
igor-c added a commit that referenced this pull request Mar 20, 2013
update from latest upstream
@igor-c igor-c merged commit 622feb1 into igor-c:master Mar 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants