Skip to content

Commit

Permalink
recompiler: fixed fragment shader built-in attribute access (shadps4-…
Browse files Browse the repository at this point in the history
…emu#1676)

* recompiler: fixed fragment shader built-in attribute access

* handle en/addr separately

* handle other registers as well
  • Loading branch information
roamic authored and diegolix29 committed Dec 7, 2024
1 parent d27ebdf commit c4ba18e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/shader_recompiler/frontend/translate/translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,37 @@ void Translator::EmitPrologue() {
} else {
ir.SetVectorReg(dst_vreg++, ir.Imm32(0.0f));
}
case LogicalStage::TessellationControl: {
ir.SetVectorReg(IR::VectorReg::V1,
ir.GetAttributeU32(IR::Attribute::PackedHullInvocationInfo));
// Test
// ir.SetPatch(IR::Patch::TessellationLodLeft, ir.Imm32(1.0f));
// ir.SetPatch(IR::Patch::TessellationLodTop, ir.Imm32(1.0f));
// ir.SetPatch(IR::Patch::TessellationLodRight, ir.Imm32(1.0f));
// ir.SetPatch(IR::Patch::TessellationLodBottom, ir.Imm32(1.0f));
// ir.SetPatch(IR::Patch::TessellationLodInteriorU, ir.Imm32(1.0f));
// ir.SetPatch(IR::Patch::TessellationLodInteriorV, ir.Imm32(1.0f));
break;
}
case LogicalStage::TessellationEval:
ir.SetVectorReg(IR::VectorReg::V0,
ir.GetAttribute(IR::Attribute::TessellationEvaluationPointU));
ir.SetVectorReg(IR::VectorReg::V1,
ir.GetAttribute(IR::Attribute::TessellationEvaluationPointV));
// I think V2 is actually the patch id within the patches running on the local CU, used in
// compiler generated address calcs,
// and V3 is the patch id within the draw
ir.SetVectorReg(IR::VectorReg::V2, ir.GetAttributeU32(IR::Attribute::TessPatchIdInVgt));
ir.SetVectorReg(IR::VectorReg::V3, ir.GetAttributeU32(IR::Attribute::PrimitiveId));
break;
case LogicalStage::Fragment:
// https://github.com/chaotic-cx/mesa-mirror/blob/72326e15/src/amd/vulkan/radv_shader_args.c#L258
// The first two VGPRs are used for i/j barycentric coordinates. In the vast majority of
// cases it will be only those two, but if shader is using both e.g linear and perspective
// inputs it can be more For now assume that this isn't the case.
dst_vreg = IR::VectorReg::V2;
for (u32 i = 0; i < 4; i++) {
ir.SetVectorReg(dst_vreg++, ir.GetAttribute(IR::Attribute::FragCoord, i));
}
if (runtime_info.fs_info.addr_flags.front_face_ena) {
if (runtime_info.fs_info.en_flags.front_face_ena) {
Expand Down
1 change: 1 addition & 0 deletions src/shader_recompiler/runtime_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <span>
#include <boost/container/static_vector.hpp>
#include "common/types.h"
#include "video_core/amdgpu/liverpool.h"
#include "shader_recompiler/frontend/tessellation.h"
#include "video_core/amdgpu/liverpool.h"
#include "video_core/amdgpu/types.h"
Expand Down

0 comments on commit c4ba18e

Please sign in to comment.