> > > If we want it to be usable for things like disassembly (and assembly), we need v_s_i to be able to express everything that *any* frontend or backend can.
>
> And I don't think we want it, it would be unmanageable.
>
> > should v-s IR exist just as a common, "neutral" format, and then we'd have basically frontend- and/or backend-specific IR that we'd do passes over?
>
> Ideally this would feel a good design to me. Though I would say that it is not a hard requirement for frontends and backends to have their specific IR, even if it is conceivable that past a certain complexity threshold it is difficult to do without. Also, my idea is that you can do passes over {front,back}end specific IRs, but also over the common IR. At least, I'd design the common IR in such a way that they can be done.
This is what I originally thought, but I'm having slight second thoughts now. The thing is that the tradeoff is now you need a new IR for every bytecode language you have, which in our case means at least sm1, sm4, and eventually I think sm6. That's a lot of extra support code to add. Consider how much we'd need to add by putting that intermediate step into HLSL -> smX translation. The advantage of making v_s_i the IR is that you don't actually need any of that.
It does feel conceptually ugly to have a CISC IR, but looking past that, I'm not sure it's that bad? Some additions (new opcodes, new register types) aren't a problem, since the backends can just vkd3d_shader_error(). Some additions (new source fields, new instruction flags) are worse, though, since now you need to make sure that nothing else cares...
It may also not be that much of a concern if the number of languages we have doesn't actually grow that large.
It may make sense to start with something underdesigned—which I think means CISC—and if that starts to get actually unwieldy, then we can start overdesigning a RISC IR to mediate.
> In practice I see a number of difficulties:
>
> * Shaders are not just code; they also embed interface information (input and output signatures, uniforms, buffers, object bindings, ...) and other random metadata (for example for the hull shaders). Should this be representable in the common IR?
We need *some* way to represent that information so it doesn't get lost, at least. I think we don't want side channels, to be clear: I think that there should be a point where all of the information relevant to a shader is represented in v_s_i format, including metadata.
And contrary to the instructions themselves, I think we want this information to be in a relatively simple and well-designed form. In a sense, it doesn't need to be "complex" like the instructions since we're not doing optimization passes over it [if that makes sense]. I think Conor has basically been pushing v_s_i in this direction in order to accommodate sm6 (at least wrt semantics), and given the tribulations I've had to endure to get sm1 to work, I think that's the right approach.
--
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/174#note_31612
Zebediah Figura (@zfigura) commented about dlls/hrtfapo/main.c:
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
> + */
> +
> +#include "hrtfapoapi.h"
> +#include "wine/debug.h"
> +
> +WINE_DEFAULT_DEBUG_CHANNEL(hrtfapo);
Let's use the existing xaudio2 channel here.
And in general, matching the style used in xaudio2 would probably be good.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2727#note_31599