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.