Mikko Rasa [Fri, 17 Oct 2014 18:30:08 +0000 (21:30 +0300)]
Allow applying a VertexArray in non-legacy mode
Mesh::bind now has consistent results whether or not vertex array objects
are available. This is unlikely to be needed on full OpenGL, but is
necessary for OpenGL ES 2.0 support (ES 3.0 has VAOs).
Mikko Rasa [Wed, 15 Oct 2014 21:12:32 +0000 (00:12 +0300)]
Delay loading matrices until they are needed
If all renderables use modern shaders, it's not necessary to touch the
system matrix stacks at all. OpenGL ES 2.0 and OpenGL 3.0 core do not
even have system matrix stacks.
Mikko Rasa [Wed, 15 Oct 2014 16:40:16 +0000 (19:40 +0300)]
Remove a number of rarely used legacy features
ShadowMap will now need shaders to work, but it was already broken in
fixed-function anyway due to using large texture unit numbers. Since
all modern hardware supports shaders, even with free drivers, this is
unlikely to be an issue.
The removed pixel format GL_RED is used in ARB_texture_rg, but we don't
support that extension yet.
Mikko Rasa [Wed, 15 Oct 2014 15:36:31 +0000 (18:36 +0300)]
Refactor and optimize the extension generator script
Overly short variable names have been expanded
parse_file was getting a bit unwieldy and has been split
getElementsByTagName is recursive and slow, replaced with custom function
Mikko Rasa [Tue, 30 Sep 2014 17:05:45 +0000 (20:05 +0300)]
Rewrite ResourceManager internals for more scalability
Since loading small resources can often take less than one frame,
especially with vsync enabled, the thread can now handle more than one
resource at once. The code is also somewhat better structured for using
more than one thread in the future.
Mikko Rasa [Mon, 29 Sep 2014 21:07:20 +0000 (00:07 +0300)]
Better handling of unloaded textures
Since it's no longer guaranteed that calling ResourceManager::resource_used
will result in Resource::load being called, it's better to avoid the
binding logic entirely in the unloaded case. In particular, parameters
must not be updated until the GL texture object has been created.
Generating an ID for the texture has been delayed to the last phase of
loading to further differentiate the loaded and unloaded states.
Mikko Rasa [Sun, 28 Sep 2014 17:54:56 +0000 (20:54 +0300)]
Put transform matrices into a uniform block too
I'm fairly certain the glBufferSubData call required to update the block
contents is no slower than the glUniformMatrix* calls to set the uniforms
directly.
Mikko Rasa [Sun, 28 Sep 2014 17:52:17 +0000 (20:52 +0300)]
Don't consider the current buffer in deciding whether to bind BufferRange
glBindBufferRange should only be called if the buffer range bound to that
index was changed. The buffer binding gets changed as a side-effect, but
should not factor into the decision.
Mikko Rasa [Sun, 28 Sep 2014 16:58:08 +0000 (19:58 +0300)]
Rework ProgramData to do less unnecessary work
Changes are now tracked per-uniform, allowing more updates to be skipped.
The buffers used in a program are cached, making the no-changes case
faster.
Additionally, Program now creates a UniformBlockInfo struct for the
default uniform. The program-wide uniform layout hash has been repurposed
to cover the entire program.
Mikko Rasa [Fri, 26 Sep 2014 15:00:18 +0000 (18:00 +0300)]
Unbind things if they are deleted while current
Failing to do so can lead to all sorts of stale-state issues, especially
if a newly created thing happens to get the exact same address as the
just deleted one.
Mikko Rasa [Mon, 16 Jun 2014 21:02:03 +0000 (00:02 +0300)]
Move extension requirements from ProgramData to UniformBlock
ProgramData no longer manipulates GL directly, and it's used in places
like Renderer and Material. This changes allows those things to be used
without shader support.
Mikko Rasa [Tue, 20 May 2014 22:09:49 +0000 (01:09 +0300)]
Rearrange ProgramBuilder's standard variables
The rgb_light_foo names were getting a bit stupid, and the hierarchy also
makes more sense this way. The use of gl_FrontLightProduct was dropped
as too cumbersome to maintain. The future is with modern shaders anyway.
Texture now only affects ambient and diffuse colors, not specular. There
will likely be support for a separate specular map in the future.
Mikko Rasa [Tue, 13 May 2014 09:21:28 +0000 (12:21 +0300)]
Tweak goal variable handling in ProgramBuilder
All variables now have types, and goal variables are recognized by the
lack of references to them. This solves a problem where non-optimized
legacy shaders would emit an assignment to frag_color without declaring
it first.
Mikko Rasa [Thu, 8 May 2014 17:55:53 +0000 (20:55 +0300)]
Don't store ProgramData in Lighting
It can't be kept up to date automatically, as Lighting can't track the
individual Lights' state. It's also hard to make optimize out unnecessary
updates. It's typically computed very few times per frame anyway, so the
performance hit is negligible (as opposed to something like Material,
which might get used hundreds or thousands of times per frame).
Mikko Rasa [Mon, 23 Dec 2013 16:14:13 +0000 (18:14 +0200)]
More flexible system for customizing generated shaders
Any standard variable can now be overridden, and new ones added. It's
still somewhat fragile concerning variable ordering and some other things,
but it works when used correctly.
Mikko Rasa [Sun, 22 Dec 2013 00:15:06 +0000 (02:15 +0200)]
Simplify VAO setup code
Previously buffer binding semantics caused complications, as index buffer
was unbound while a mesh was bound so batches couldn't be updated. Now
that buffers behave better with bounds meshes, batches can take care of
themselves again.
Triggering the setup from bind() instead of draw() gets rid of another
bunch of complications, since it will only be called when the VAO is going
to be actually used.