diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp index 08f549522..6d53bc06c 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp @@ -515,7 +515,8 @@ std::set ValidateShaders(std::span shaders, const auto attachments = std::max(state.colors.size(), 1u); std::set locations; for (const auto& [location, signature] : previous.outputs) { - Require(location < attachments && signature == "vertex:f32x4", "fragment shader must export float4 colors at locations below the attachment count"); + if (location >= attachments) continue; + Require(signature == "vertex:f32x4", "fragment shader must export float4 colors to its attachments"); locations.insert(location); } return locations; diff --git a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp index dacf921c2..aa028756f 100644 --- a/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Graphics.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -771,6 +772,7 @@ struct ModuleShape { std::uint32_t perVertexLength = 3; bool parameterOutput = false; bool rectParameters = false; + bool secondTarget = false; }; void emit(std::vector& out, spv::Op op, std::initializer_list operands) { @@ -809,6 +811,12 @@ std::vector makeModule(const ModuleShape& shape) { emit(annotations, spv::OpDecorate, {parameter, spv::DecorationLocation, 0}); extraInterface.push_back(parameter); } + if (shape.secondTarget) { + const auto target = id(); + emit(declarations, spv::OpVariable, {outputPointer, target, spv::StorageClassOutput}); + emit(annotations, spv::OpDecorate, {target, spv::DecorationLocation, 1}); + extraInterface.push_back(target); + } if (shape.rectParameters) { const auto pointer = id(); emit(declarations, spv::OpTypePointer, {pointer, spv::StorageClassInput, vectorType}); @@ -1003,6 +1011,15 @@ void validationTests() { pixel.spirv = makeModule({.fragment = true}); expectFailure([&] { AgcDriver::Graphics::ValidateShaders(shaders, state, subgroup, true); }, "requires a fragment shader"); } + { + ShaderRecompiler::RecompileResult vertex; + vertex.spirv = makeModule({}); + ShaderRecompiler::RecompileResult pixel; + pixel.spirv = makeModule({.fragment = true, .secondTarget = true}); + const std::array shaders{{{ShaderRecompiler::ShaderStage::Vertex, &vertex, 0}, {ShaderRecompiler::ShaderStage::Fragment, &pixel, 0}}}; + const VkPhysicalDeviceSubgroupProperties subgroup{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES}; + Require(state.colors.empty() && AgcDriver::Graphics::ValidateShaders(shaders, state, subgroup, false) == std::set{0u}, "an export past the attachments was not dropped"); + } { ShaderRecompiler::RecompileResult vertex; vertex.spirv = makeModule({.vertexInput = true});