On 13 December 2012 03:44, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Patches 1 through 4 are<br>
<br>
Reviewed-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
<br>
I'll try to make it through the rest tomorrow. I have skimmed them, and it looks mostly okay. I thing a good follow-up patch will be to pull a bunch of the new stuff out to a new file link_varyings.cpp or something. linker.cpp is getting a bit out of control. ~2700 lines in one file...</blockquote>
<div><br>Yeah, that seems reasonable, especially since there's additional varying packing work to do this series. I'll do that after the series lands.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
<br>
On 12/11/2012 03:09 PM, Paul Berry wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
This patch series adds varying packing to Mesa, so that we can handle<br>
varyings composed of things other than vec4's without using up extra<br>
varying components.<br>
<br>
For the initial implementation I've chosen a strategy that operates<br>
exclusively at the GLSL IR level, so that it doesn't require the<br>
cooperation of the driver back-ends. This means that varying packing<br>
should be immediately useful for all drivers. However, there are some<br>
types of varying packing that can't be done using GLSL IR alone (for<br>
example, packing a "noperspective" varying and a "smooth" varying<br>
together), but should be possible on some drivers with a small amount<br>
of back-end work. I'm deferring that work for a later patch series.<br>
Also, packing of floats and ints together into the same "flat varying"<br>
should be possible for drivers that implement<br>
ARB_shader_bit_encoding--I'm also deferring that for a later patch<br>
series.<br>
<br>
The strategy is as follows:<br>
<br>
- Before assigning locations to varyings, we sort them into "packing<br>
classes" based on base type and interpolation mode (this is to<br>
ensure that we don't try to pack floats with ints, or smooth with<br>
flat, for example).<br>
<br>
- Within each packing class, we sort the varyings based on the number<br>
of vector elements. Vec4's (as well as matrices and arrays composed<br>
of vec4's) are packed first, then vec2's, then scalars, since this<br>
allows us to align them all to their natural alignment boundary, so<br>
we avoid the performance penalty of "double parking" a varying<br>
across two varying slots. Vec3's are packed last, double parking<br>
them if necessary.<br>
<br>
- For any varying slot that doesn't contain exactly one vec4, we<br>
generate GLSL IR to manually pack/unpack the varying in the shader.<br>
For instance, the following fragment shader:<br>
<br>
varying vec2 a;<br>
varying vec2 b;<br>
varying vec3 c;<br>
varying vec3 d;<br>
main()<br>
{<br>
...<br>
}<br>
<br>
would get rewritten as follows:<br>
<br>
varying vec4 packed0;<br>
varying vec4 packed1;<br>
varying vec4 packed2;<br>
vec2 a;<br>
vec2 b;<br>
vec3 c;<br>
vec3 d;<br>
main()<br>
{<br>
a = packed0.xy;<br>
b = <a href="http://packed0.zw" target="_blank">packed0.zw</a>;<br>
c = packed1.xyz;<br>
d.x = packed1.w; // d is "double parked" across slots 1 and 2<br>
d.yz = packed2.xy;<br>
...<br>
}<br>
<br>
This GLSL IR is generated by a lowering pass, so that in the future<br>
we will have the option of disabling it for driver back-ends that<br>
are capable of natively understanding the packed varying format.<br>
<br>
- Finally, the linker code to handle transform feedback is modified to<br>
account for varying packing (e.g. by feeding back just a subset of<br>
the components of a varying slot rather than the entire varying<br>
slot). Fortunately transform feedback already has the<br>
infrastructure necessary to do this, since it was needed in order to<br>
implement glClipDistance.<br>
<br>
<br>
I believe this is enough to be useful for the vast majority of<br>
programs, and to get us passing the GLES3 conformance tests.<br>
<br>
<br>
Additional improvements, which I'm planning to defer to later patch<br>
series, include:<br>
<br>
- Allow uints and ints to be packed together in the same varying slot.<br>
This should be possible on all back-ends, since ints and uints may<br>
be interconverted without losing information.<br>
<br>
- On back-ends that support ARB_shader_bit_encoding, allow floats and<br>
ints to be packed together in the same varying slot, since<br>
ARB_shader_bit_encoding allows floating-point values to be encoded<br>
into ints without losing information.<br>
<br>
- On back-ends that can mix interpolation modes within a single<br>
varying slot, allow additional packing, with help from the driver<br>
back-end. For instance, i965 gen6 and above can in principle mix<br>
together all interpolation modes except for "flat" within a single<br>
varying slot, if we do a hopefully small amount of back-end work.<br>
<br>
- Allow a driver back-end to advertise a larger number of varying<br>
components to the linker than it advertises to the client<br>
program--this will allow us to ensure that varying packing *never*<br>
fails. For example, on i965 gen6 and above, after the above<br>
improvements are made, we should be able to pack any possible<br>
combination of varyings with a maximum waste of 3 varying<br>
components. That means, for example, that if the i965 driver<br>
advertises 17 varying slots to the linker (== 68 varying<br>
components), but advertises only 64 varying components to the the<br>
client program, then varying packing will always succeed.<br>
<br>
Note: I also have a new piglit test that exercises this code; I'll be<br>
publishing that to the Piglit list ASAP.<br>
<br>
[PATCH 01/10] glsl/lower_clip_distance: Update symbol table.<br>
[PATCH 02/10] glsl/linker: Always invalidate shader ins/outs, even in corner cases.<br>
[PATCH 03/10] glsl/linker: Make separate ir_variable field to mean "unmatched".<br>
[PATCH 04/10] glsl: Create a field to store fractional varying locations.<br>
[PATCH 05/10] glsl/linker: Defer recording transform feedback locations.<br>
[PATCH 06/10] glsl/linker: Subdivide the first phase of varying assignment.<br>
[PATCH 07/10] glsl/linker: Sort varyings by packing class, then vector size.<br>
[PATCH 08/10] glsl: Add a lowering pass for packing varyings.<br>
[PATCH 09/10] glsl/linker: Pack within compound varyings.<br>
[PATCH 10/10] glsl/linker: Pack between varyings.<br></div></div>
______________________________<u></u>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>