Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Force uniform update on first use #57

Merged
merged 3 commits into from

3 participants

@igor-c

This is a patch that fixes an issue with uninitialized uniforms for me. The issue happens rarely, but it does happen. Please let me know if there's a better way to fix it and I will be happy to rework the CL.

igor-c and others added some commits
@igor-c igor-c Merge pull request #6 from p3/master
update from latest upstream
622feb1
@igor-c igor-c Merge pull request #7 from p3/master
pull latest upstream code
ad0522c
Igor Chernyshev Force uniform update on first use.
In most new programs "ver" is updated through UpdateMatrixVer().
However, when that does not happen a program may end up being
unusable as uniforms are not set correctly.
c051c05
@casseveritt
Owner
@igor-c

I was very curious about that as well. However, not knowing how versions are supposed to be updated and synchronized, there was very little I could investigate. Could you give some update on how versions are supposed to be updated and synchronized? They appear to be on quite a few levels and a few of them may get assigned at the same time.

@nigels-com
Collaborator

Cass, should these unsigned 64-bit integers be wrapped into a struct that will default-construct to -1 instead of 0?

  • Nigel
@casseveritt
Owner

There's one instance of Version in the Iff class. It is sort of a timestamp. Its goal is to be monotonically increasing as state settings occur, but no more frequently than draw calls that use that state. (With a 64b counter, it's unnecessary to limit the increments this way, and maybe we shouldn't bother.) Fixed-function state is in a single hierarchical structure that has timestamps at various levels of the hierarchy. The idea is when you update some state, you capture the timestamp at that time and you propagate that timestamp up to the root. This all goes on independent of shaders that actually reference the state.

There can be many shaders, both fixed-function and user-specified, that reference this state as program uniforms. Because program uniforms are program-local (until UBO is ubiquitous), each program has a cached copy of each piece of uniform state it references along with the version timestamp when it was captured. At draw time, each fixed-function uniform is checked to see if it is out of date. If the version numbers match, it is not out of date and no update occurs. If the version numbers don't match, the uniform and its version number updated immediately before the draw.

@casseveritt
Owner

Yes, Nigel, that's probably a good idea.

@nigels-com
Collaborator

I'll merge this patch as-is. But I'm concerned that initializing all the timestamps to -1 will put us back where we started, in terms of detecting when uniforms need to be sent. Can we change the logic from == to < ?

@nigels-com nigels-com merged commit c051c05 into p3:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2013
  1. @igor-c

    Merge pull request #6 from p3/master

    igor-c authored
    update from latest upstream
Commits on Mar 21, 2013
  1. @igor-c

    Merge pull request #7 from p3/master

    igor-c authored
    pull latest upstream code
  2. Force uniform update on first use.

    Igor Chernyshev authored
    In most new programs "ver" is updated through UpdateMatrixVer().
    However, when that does not happen a program may end up being
    unusable as uniforms are not set correctly.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/regal/RegalIff.cpp
View
2  src/regal/RegalIff.cpp
@@ -1378,7 +1378,7 @@ void Program::Init( RegalContext * ctx, const Store & sstore, const GLchar *vsSr
{
Internal("Regal::Program::Init","()");
- ver = 0;
+ ver = -1; // Force uniform update on first use.
progcount = 0;
RegalAssert(ctx);
DispatchTable & tbl = ctx->dispatcher.emulation;
Something went wrong with that request. Please try again.