Bug 89436 - Add NIR functions for copying instructions, blocks, functions, and whole shaders
Summary: Add NIR functions for copying instructions, blocks, functions, and whole shaders
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium enhancement
Assignee: Rob Clark
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-05 04:03 UTC by Jason Ekstrand
Modified: 2018-01-17 04:34 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Jason Ekstrand 2015-03-05 04:03:29 UTC
The idea here is two write the C equivalent of "copy constructors" for NIR datatypes.  Not everything needs a copy constructor but, at the very least, we at least need to be able to do a deep copy nir_function_impl's and everything they contain.  Most of this should be straightforward as it's simply a matter of recursing into data structures and copying everything.

There is a little complication when it comes to variables, registers, and SSA values, however.  When we copy functions we will need some sort of a "remap table" so that the copied functions can use the copied variables/registers/SSA values rather than the originals.

Also, we have to be a bit careful with nir_phi_instr's as the SSA definitions they use in their sources may not come before they do in the shader.  For these, we have to create the actual instructions first and then fill out their sources as a seperate pass after the rest of the instructions have been created.  In fact, it may be easier (for the sake of correctness) to use this sort of two-step copying procedure for all instructions.
Comment 1 Rob Clark 2015-10-20 20:06:45 UTC
I need something along the lines of nir_shader_clone() for my gallium glsl->nir patchset, so I'll start working on this (assuming no one else has.. if I'm stepping on any toes, please speak up!)

Mostly I plan to implement cloning of entire shader (although I think after that cloning nir_function_impl's, etc, should be trivial)
Comment 2 Kenneth Graunke 2015-10-21 22:12:10 UTC
Awesome, thanks Rob!
Comment 3 Jason Ekstrand 2018-01-17 04:34:39 UTC
This has existed for a long time.  We're really bad at actually closing feature bugs.  Thanks Rob!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.