GCN has the concept of hardware and software stages. Software stages are the shader stages exposed in graphics APIs like opengl/vulkan, and each software stage runs on a hardware stage.
Depending on how many and what software stages are used in a graphics pipeline, the hardware stage a software one is executed on can change, so the mapping is not fixed.
The following table from ACO describes the various combinations for HW-SW stages: https://gitlab.freedesktop.org/mesa/mesa/-/blob/c90ae5f7/src/amd/compiler/README.md#gfx6-8
Certain software stages like the vertex and tess eval shader can run a lot of different hardware stages, which creates problems because runtime info is a tagged union on HW stage.
Current main uses struct inheritance to make it work, but that will get clunky when more data is added to other stages. In general there is a lack of separation between what data
is required when a HW stage is used and what for SW stage.
An example is the tess_emulated_primitive variable. This is used for skipping exports in a software vertex shader when tessellation stages have been inserted after it
for Quad/RectList emulation, because it is undefined behavior to not export them from the last geometry stage. Having this data field in the HW vertex info is not semantically
correct because HW vertex is always the last geometry stage that runs. So this only works when there isnt any HW geometry shader active, as the HW vertex shader is not normally processed in that case.
Another example is shader specialization previously checked the HW vertex stage to specialize the fetch shader. This only works on simple VS+PS pipelines when HW VS runs the SW VS.
Fetch shader is part of the SW VS state, its run on first geometry stage not the last, and this issue got exposed because of the new state separation.
This commit refactors runtime info to contain two tagged unions, one from SW stage and the other HW stage. This makes it obvious what is the scope of each state.
When recompiler does a switch on sw stage, it becomes more apparent it should only access sw state members unless it also checks which hw stage it runs on, which will result in less bugs
* shader_recompiler: Split resource tracking into 2 parts and flatten load from buffer if used as sharp source
clang-format
fix inmediate sample raw
defer sharp not found asserts
flip asserts
disable aniso pattern
fix disable aniso
some fixes
non immediate
fix PushPtr
fix PushPtr for non immediate
don't assert on offset computation failures
robust bfs
some xbyak fixes
add bitwise ops
umin umax and bit extract
correct rshift lshift 0st immediate
fix and in memory
some minor code fixes
consider ReadConstBuffer as valid finding
fix xbyak
fix magic_enum for opcodes
fix building (yes, i didn't test)
don't corrupt stack when bailing out
ReadConstBuffer compute offset
use canonical inst for readconst non-imm offset
mark all readconstbuffer sharp dwords
consider r128 images
FindSharpLocation
handle non-imm offset readconstbuffer
don't handle immediates when constant folding
proper check for ReadConst to get flatbuf offset
clang-format
fix stupidity
invert condition
separate search dominant function
handle phis loke other insts in gvn
use same logic for phis in gvn than for flatten pass
apparently idk how logic works
revert back to old logic
min/max immediate in constant folding
add offset insts to gvn inst to hash args
assert that ReadConstsBuffer insts have usage as buffer sharp
separate dominance search from bfs
chang gvn phi handling
remove unused includes
fix reuse
readconst transform add address
* shader_recompiler: Move readconst address add simplification to flatten pass
* shader_recompiler: Remove unnecessary phi handling
Now sharp tracking should be much simpler since its on the unstructured control flow graph
* shader_recompiler: Only enable DMA if some ReadConst could not be flattened
* shader_recompiler: Improve phi eliminaton of readlane elimination with worklist
* shader_recompiler: Cascade flattening failure in ReadConst tree, bind null sharp when source could not be flattened
* shader_recompiler: Further improve robustness of tracking
- Track all dwords of T# with SSA
- Ensure sharp dwords are sequential in flatbuf memory
- Substitue null descriptors on tracking failures
* shader_recompiler: Add new sharp fetching object
* shader_recompiler: Add new sampler pattern
* shader_recompiler: Add texture cube to 2d array pattern
* control_flow_graph: Remove unreachable blocks
Fix bloodborne
* shader_recompiler: Add yet another sampler pattern
* shader_recompiler: Add sampler aniso pattern
* flatten_extended_userdata: Only search through allowed instructions
* some fixes
* :kek:
* tests: Fix tests compile
---------
Co-authored-by: raphaelthegreat <geoster3d@gmail.com>