[Mesa-dev] i965: Pushing UBO values, NIR, etc.

Kenneth Graunke kenneth at whitecape.org
Wed Nov 19 21:51:50 PST 2014


I've been wondering about the best approach to handle UBO values as push
constants.  Right now, we always treat them as pull constants, which means
sending messages and hitting memory (or at least the sampler cache) - it's
quite inefficient.

3DSTATE_CONSTANT_* can read a contiguous block of constant data from up to
four arbitrary buffer objects.  They do not have to be relative to dynamic
state base address; you simply have to set a bit in INSTPM and use relocs.

I have that working in a branch today:

Our current GLSL IR backend's approach to uniforms makes this really painful,
though.  Regular uniforms show up in the i965 backend as if they were push
constants (UNIFORM registers), and are demoted to pull constants in some
circumstances.  In contrast, UBOs show up as pulls (ir_binop_ubo_load), and
we'd like to turn them into push constants - the exact opposite!

Converting both ways would be crazy, and the separate representations make it
hard to decide how many (and which) regular uniforms and UBO values to push.
Ideally, we could decide how many to push based on estimated register pressure,
and decide which based on usage (if they're used near the end of the shader,
pushing would create a huge live range), and taking into account the constraint
that we can only push contiguous blocks (in the UBO case - regular uniforms
are always packed already).

My hope is that with the move to NIR, we can represent incoming uniform values
in a consistent manner.  My gut feeling is that we should treat all uniform
values as memory loads.  We'd do the above partitioning into push/pull
constants, then lower the memory loads.

For pull constants, the "uniform load" operation would become an LD message.  
For push constants, the "uniform load" would simply turn into a MOV from a 
payload register, which could be optimized away by copy propagation or 
register coalescing.

Being able to push UBO values could dramatically improve "Witcher 2" 
performance, which is currently completely unplayable even on Iris Pro.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141119/8d8563f6/attachment.sig>

More information about the mesa-dev mailing list