Hello, 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: http://cgit.freedesktop.org/~kwg/mesa/commit/?h=ubopush&id=1e2edd311846bfed6ebc1a775854c95c2efa4467 http://cgit.freedesktop.org/~kwg/mesa/commit/?h=ubopush&id=65a2fb0f4b1065bc1f40a2e4b577bd61980ef829 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. --Ken
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev