Search Unity

What's the point of assigning a register...?

Discussion in 'Shaders' started by justin_kasowski, Jul 13, 2020.

  1. justin_kasowski

    justin_kasowski

    Joined:
    Jan 14, 2020
    Posts:
    45
    My understanding was that a register assigned a location in memory so that your CPU knows where to access it. Every guide on how to make a RWStructured Buffer says to assign a register.

    Someone working on my project didn't assign a register but their code still runs. Being curious, I removed all the assigned registers from the rest of our code and everything still runs perfectly. Obviously my understanding of a register is off. Can someone explain what it is and when it's needed.

    Thanks!!

    * For clarification: I'm writing to the RWStructured Buffer inside of a shader
     
    Last edited: Jul 13, 2020
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    My understanding is most of the time these will get auto-assigned, at least on Windows. However that might not work on all platforms. And if you have multiple RW buffers there's no guarantee all the shaders will use the same register(s) for the same buffer.
     
  3. justin_kasowski

    justin_kasowski

    Joined:
    Jan 14, 2020
    Posts:
    45
    Thanks!!!