Scope of the attributes to find variables


I want to find out the scope of attribute variables. I do not know how. Can someone help me?

Declare attribute variables inside the intersection program.
Calculate and write them only between rtPotentialIntersection and rtReportIntersection there.

Declare the same variables around the anyhit and closesthit programs as needed (unused ones get removed as dead code from the intersection program) and read them there (no write access).

No other scope (e.g. ray generation, miss) can access these attribute variables because there had been no intersection in that case.

You can pass data on to other program domains via the variable with rtPayload semantic.
See this table which program domain can read or read/write different semantic variables.