mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 02:47:02 +02:00
Preserve vertex export locations for mixed pixel interpolation
This commit is contained in:
@@ -1353,6 +1353,7 @@ struct GraphicsCase {
|
||||
std::vector<u32> push_constants;
|
||||
std::vector<u32> pixel_interpolator_settings;
|
||||
bool pixel_no_perspective = false;
|
||||
bool provoking_vtx_last = false;
|
||||
std::vector<u32> vertices;
|
||||
bool pixel_ancillary = false;
|
||||
bool pixel_front_face = false;
|
||||
@@ -1449,6 +1450,20 @@ void CheckPixelParameterAliases() {
|
||||
pixel.interpolator_settings[1] = 0u;
|
||||
pixel.interpolator_settings[2] = 1u;
|
||||
const std::array<uint32_t, 3> active = {0, 1, 2};
|
||||
Require(name, "ordinary mixed aliases",
|
||||
ShaderPixelParameterLocation(pixel, active, 0) == 0u &&
|
||||
ShaderPixelParameterLocation(pixel, active, 1) == 0u &&
|
||||
ShaderPixelParameterLocation(pixel, active, 2) == 1u,
|
||||
"flat/smooth aliases must retain the real vertex export location");
|
||||
std::vector<uint32_t> ordinary_key, rectangle_key, provoking_key;
|
||||
BuildStageStaticKey(pixel, ordinary_key);
|
||||
pixel.parameter_mode = ShaderPixelParameterMode::LastVertex;
|
||||
BuildStageStaticKey(pixel, provoking_key);
|
||||
pixel.parameter_mode = ShaderPixelParameterMode::Rectangle;
|
||||
BuildStageStaticKey(pixel, rectangle_key);
|
||||
Require(name, "interpolation specialization",
|
||||
ordinary_key != rectangle_key && ordinary_key != provoking_key,
|
||||
"rectangle and provoking-vertex modes must participate in the shader key");
|
||||
Require(name, "reserved physical locations",
|
||||
ShaderPixelParameterLocation(pixel, active, 0) == 0u &&
|
||||
ShaderPixelParameterLocation(pixel, active, 1) == 2u &&
|
||||
@@ -1473,6 +1488,7 @@ void CheckRectListShaders() {
|
||||
vertex.stage.program = &vertex_program;
|
||||
vertex.stage.resources = &empty_snapshot;
|
||||
ShaderPixelInputInfo pixel{};
|
||||
pixel.parameter_mode = ShaderPixelParameterMode::Rectangle;
|
||||
pixel.input_num = 2;
|
||||
pixel.interpolator_settings[0] = 0x400u;
|
||||
pixel.interpolator_settings[1] = 0;
|
||||
@@ -1774,6 +1790,8 @@ CompiledShader CompileFragmentCase(const GraphicsCase &test) {
|
||||
? 1u
|
||||
: static_cast<u32>(test.pixel_interpolator_settings.size());
|
||||
pixel_info.ps_no_perspective = test.pixel_no_perspective;
|
||||
pixel_info.parameter_mode = test.provoking_vtx_last ? ShaderPixelParameterMode::LastVertex
|
||||
: ShaderPixelParameterMode::FirstVertex;
|
||||
pixel_info.ps_ancillary = test.pixel_ancillary;
|
||||
pixel_info.ps_front_face = test.pixel_front_face;
|
||||
pixel_info.ps_pos_w = test.pixel_position_w;
|
||||
@@ -16928,6 +16946,12 @@ public:
|
||||
raster.frontFace = vk::FrontFace::eCounterClockwise;
|
||||
raster.lineWidth = 1.0f;
|
||||
|
||||
vk::PipelineRasterizationProvokingVertexStateCreateInfoEXT provoking_vertex{};
|
||||
if (test.provoking_vtx_last) {
|
||||
provoking_vertex.provokingVertexMode = vk::ProvokingVertexModeEXT::eLastVertex;
|
||||
raster.pNext = &provoking_vertex;
|
||||
}
|
||||
|
||||
vk::PipelineMultisampleStateCreateInfo multisample{};
|
||||
multisample.sType = vk::StructureType::ePipelineMultisampleStateCreateInfo;
|
||||
multisample.rasterizationSamples = test.samples;
|
||||
@@ -35871,6 +35895,38 @@ GraphicsCase GraphicsSmoothRawInputAlias() {
|
||||
return test;
|
||||
}
|
||||
|
||||
GraphicsCase GraphicsSmoothFlatInputAlias(bool flat_first, bool provoking_last = false) {
|
||||
auto test = GraphicsSmoothRawInputAlias();
|
||||
test.name = provoking_last
|
||||
? (flat_first ? "GraphicsFlatSmoothAliasLast" : "GraphicsSmoothFlatAliasLast")
|
||||
: (flat_first ? "GraphicsFlatSmoothInputAlias" : "GraphicsSmoothFlatInputAlias");
|
||||
test.pixel_custom_interpolation_mask = 0;
|
||||
test.provoking_vtx_last = provoking_last;
|
||||
test.pixel_interpolator_settings = flat_first ? std::vector<u32>{0x400u, 0u}
|
||||
: std::vector<u32>{0u, 0x400u};
|
||||
const u32 smooth = flat_first ? 1u : 0u;
|
||||
const u32 flat = smooth ^ 1u;
|
||||
// One export carries smooth values (2,4,8) and packed light IDs (5,7,11).
|
||||
// Flat P0 preserves the ID bits; flat P1/P2 uses the same provoking vertex.
|
||||
test.vertices[4] = 0x3f800005u;
|
||||
test.vertices[10] = 0x3f800007u;
|
||||
test.vertices[16] = 0x3f80000bu;
|
||||
test.fragment_code = {EncodeVintrp(0x00, 0, smooth, 1, 0),
|
||||
EncodeVintrp(0x01, 0, smooth, 1, 1),
|
||||
EncodeVintrp(0x02, 1, flat, 2, 2),
|
||||
EncodeVop2(0x1b, 1, InlineU32(63), 1),
|
||||
EncodeVop1(0x06, 1, Vgpr(1)),
|
||||
EncodeVintrp(0x00, 2, flat, 1, 0),
|
||||
EncodeVintrp(0x01, 2, flat, 1, 1),
|
||||
EncodeExp0(0x00, 0xf), EncodeExp1(0, 1, 2, 0)};
|
||||
AppendEnd(&test.fragment_code);
|
||||
test.expected_pixel = {0x40700000u, provoking_last ? 0x41300000u : 0x40a00000u,
|
||||
provoking_last ? 0x41000000u : 0x40000000u, 0x40700000u};
|
||||
test.opcodes.insert(test.opcodes.end(),
|
||||
{ShaderOpcode::V_AND_B32, ShaderOpcode::V_CVT_F32_U32});
|
||||
return test;
|
||||
}
|
||||
|
||||
GraphicsCase GraphicsAncillaryLayer(bool front_face) {
|
||||
GraphicsCase test;
|
||||
test.name = front_face ? "GraphicsAncillaryAfterFrontFace" : "GraphicsAncillaryLayer";
|
||||
@@ -36714,6 +36770,10 @@ std::vector<GraphicsCase> MakeGraphicsCases() {
|
||||
GraphicsPackedHalfInputAlias(false),
|
||||
GraphicsPackedHalfInputAlias(true),
|
||||
GraphicsSmoothRawInputAlias(),
|
||||
GraphicsSmoothFlatInputAlias(false),
|
||||
GraphicsSmoothFlatInputAlias(true),
|
||||
GraphicsSmoothFlatInputAlias(false, true),
|
||||
GraphicsSmoothFlatInputAlias(true, true),
|
||||
GraphicsAncillaryLayer(false),
|
||||
GraphicsAncillaryLayer(true),
|
||||
GraphicsAncillarySampleId(),
|
||||
@@ -42196,6 +42256,11 @@ int main(int argc, char **argv) {
|
||||
RunGraphicsCase(&vulkan, GraphicsPackedHalfInputAlias(false));
|
||||
RunGraphicsCase(&vulkan, GraphicsPackedHalfInputAlias(true));
|
||||
RunGraphicsCase(&vulkan, GraphicsSmoothRawInputAlias());
|
||||
RunGraphicsCase(&vulkan, GraphicsSmoothFlatInputAlias(false));
|
||||
RunGraphicsCase(&vulkan, GraphicsSmoothFlatInputAlias(true));
|
||||
RunGraphicsCase(&vulkan, GraphicsSmoothFlatInputAlias(false, true));
|
||||
RunGraphicsCase(&vulkan, GraphicsSmoothFlatInputAlias(true, true));
|
||||
RunGraphicsCase(&vulkan, GraphicsFlatInterpolatorExport());
|
||||
return 0;
|
||||
}
|
||||
if (argc == 2 && std::strcmp(argv[1], "--clip-control-only") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user