mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 03:16:54 +02:00
shader: initialize perspective sample barycentrics at SampleId
This commit is contained in:
@@ -6539,6 +6539,7 @@ void TestPerspectiveCentroidInputs() {
|
||||
ShaderMapUserData(regs.ps_regs.data_addr, mapped);
|
||||
HW::ShaderRegisters sh{};
|
||||
sh.ps_input_ena = sh.ps_input_addr = inputs;
|
||||
sh.m_cbShaderMask = 0xf;
|
||||
const std::array<Prospero::ColorComponentMapping, 8> mappings{};
|
||||
ShaderPixelInputInfo pixel{};
|
||||
(void)PrepareProgram(regs, sh, mappings, pixel);
|
||||
@@ -6570,6 +6571,47 @@ void TestPerspectiveCentroidInputs() {
|
||||
}
|
||||
}
|
||||
|
||||
void TestPerspectiveSampleInputs() {
|
||||
for (const uint32_t inputs : {1u, 3u, 5u, 7u}) {
|
||||
const std::vector<uint32_t> shader = {
|
||||
EncodeExp0(0x00, 0xf),
|
||||
EncodeExp1(0, 1, inputs == 1 ? 0 : 2, inputs == 1 ? 1 : 3),
|
||||
EncodeSopp(0x01)};
|
||||
HW::PixelShaderInfo regs{};
|
||||
regs.ps_regs.data_addr = reinterpret_cast<uint64_t>(shader.data());
|
||||
ShaderMappedData mapped{};
|
||||
mapped.code_size_bytes = shader.size() * sizeof(uint32_t);
|
||||
ShaderMapUserData(regs.ps_regs.data_addr, mapped);
|
||||
HW::ShaderRegisters sh{};
|
||||
sh.ps_input_ena = sh.ps_input_addr = inputs;
|
||||
sh.m_cbShaderMask = 0xf;
|
||||
const std::array<Prospero::ColorComponentMapping, 8> mappings{};
|
||||
ShaderPixelInputInfo pixel{};
|
||||
(void)PrepareProgram(regs, sh, mappings, pixel);
|
||||
Check(pixel.ps_perspective_sample_vgpr == 0 &&
|
||||
pixel.ps_system_input_base == 2u * std::popcount(inputs),
|
||||
"perspective sample pair did not occupy the first enabled VGPRs");
|
||||
const auto key = MakeStageStaticKey(pixel);
|
||||
pixel.ps_perspective_sample_vgpr = UINT32_MAX;
|
||||
Check(key != MakeStageStaticKey(pixel), "sample input is missing from shader key");
|
||||
pixel.ps_perspective_sample_vgpr = 0;
|
||||
auto options = MakeCompileOptions(ShaderType::Pixel);
|
||||
options.input_info.pixel = &pixel;
|
||||
const auto result = RecompileForTest(shader, options);
|
||||
const auto source = DisassembleSpirvBinary(result.spirv);
|
||||
Check(SpirvContainsCapability(result.spirv, 52u) &&
|
||||
SpirvHasDecorationValue(result.spirv, 11u, 18u) &&
|
||||
source.find("InterpolateAtSample %gl_BaryCoordKHR") != std::string::npos &&
|
||||
SpirvSourceHasInstructionUsing(source, "OpLoad", "%int %gl_SampleID") &&
|
||||
SpirvSourceHasInstructionUsing(source, "OpCompositeExtract", " 1") &&
|
||||
SpirvSourceHasInstructionUsing(source, "OpCompositeExtract", " 2"),
|
||||
"sample I/J did not evaluate BaryCoordKHR Y/Z at SampleId");
|
||||
Check(!SpirvHasDecorationValueWithDecoration(result.spirv, 11u, 5286u, 17u),
|
||||
"sample interpolation changed the shared barycentric input location");
|
||||
CheckSpirvBinaryValidates(result.spirv);
|
||||
}
|
||||
}
|
||||
|
||||
void TestPsInputCountRegisterDecode() {
|
||||
HW::Context context;
|
||||
// NUM_INTERP is 3 while bit 14 is an independent control flag that must be
|
||||
@@ -15054,6 +15096,7 @@ int main() {
|
||||
TestNewShaderRecompilerStageInputInfo();
|
||||
TestCustomVintrpMovTranslation();
|
||||
TestPerspectiveCentroidInputs();
|
||||
TestPerspectiveSampleInputs();
|
||||
TestGraphicsCreateInterpolantMapping();
|
||||
TestNewShaderRecompilerPixelPipelineEntry();
|
||||
TestComputeLdsAllocationIdentity();
|
||||
|
||||
Reference in New Issue
Block a user