Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void Driver::lookupDraw(const Submission& submission, const std::shared_ptr<Vulk
mix(tess.mergedHull);
}
mix(graphics.rectList);
mix(graphics.rasterizerDiscard);
mix(programs.size());
for (std::size_t i = 0; i < programs.size(); ++i) {
const auto& program = programs[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ bool Driver::sameDecode(const DrawDecode& a, const DrawDecode& b) {
for (std::size_t i = 0; i < s.blends.size(); ++i) {
if (!sameBlend(s.blends[i], t.blends[i])) return false;
}
if (s.colorRop != t.colorRop || s.hasColorTarget != t.hasColorTarget || s.rectList != t.rectList || s.renderExtent.width != t.renderExtent.width || s.renderExtent.height != t.renderExtent.height || s.topology != t.topology || s.negativeOneToOne != t.negativeOneToOne || s.depthClamp != t.depthClamp || s.conservativeRasterization != t.conservativeRasterization || s.perSampleShading != t.perSampleShading || s.cullMode != t.cullMode || s.polygonMode != t.polygonMode || s.lineWidth != t.lineWidth || s.frontFace != t.frontFace || !sameBlend(s.blend, t.blend) || s.blendConstants != t.blendConstants) return false;
if (s.colorRop != t.colorRop || s.hasColorTarget != t.hasColorTarget || s.rectList != t.rectList || s.rasterizerDiscard != t.rasterizerDiscard || s.renderExtent.width != t.renderExtent.width || s.renderExtent.height != t.renderExtent.height || s.topology != t.topology || s.negativeOneToOne != t.negativeOneToOne || s.depthClamp != t.depthClamp || s.conservativeRasterization != t.conservativeRasterization || s.perSampleShading != t.perSampleShading || s.cullMode != t.cullMode || s.polygonMode != t.polygonMode || s.lineWidth != t.lineWidth || s.frontFace != t.frontFace || !sameBlend(s.blend, t.blend) || s.blendConstants != t.blendConstants) return false;
if (std::memcmp(&s.viewport, &t.viewport, sizeof(VkViewport)) != 0 || std::memcmp(&s.scissor, &t.scissor, sizeof(VkRect2D)) != 0) return false;
const auto& p = a.pixel;
const auto& q = b.pixel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ Module Inspect(const CompiledShader& compiled, const State& state, const VkPhysi
if (mesh) Require(module.primitiveIndices == state.stages.mesh->outputPrimitiveSize, "mesh shader does not export primitive indices");
if (fragment) Require(module.primitiveInputs == 0 || !primitiveLocations.empty(), "per-primitive pixel inputs need the barycentric emulation layout");
if (fragment) Require(!module.meshCapability || module.primitiveInputs != 0, "a pixel shader declares mesh shading without a per-primitive input");
if (stage == Stage::Vertex || mesh || ((evaluation || geometry) && !state.rasterizerDiscard)) Require(module.position, "vertex shader does not export position");
if (mesh || ((stage == Stage::Vertex || evaluation || geometry) && !state.rasterizerDiscard)) Require(module.position, "vertex shader does not export position");
return module;
}

Expand Down
7 changes: 6 additions & 1 deletion core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,12 @@ State DecodeState(const QueueState& queue, bool vertexWorkgroup) {
APS5_LOG_OUT_DEBUG("Export format=%u", exportFormat);
// SPI_SHADER_POS_FORMAT: POS0 must be a 4-component position; later vectors carry the misc/clip
// exports that PA_CL_VS_OUT_CNTL validation above already limits to ignored layer/viewport data.
Require((read(cx, 0x1c3) & 0xfu) == 4, "additional position exports are unsupported");
const auto positionFormat = read(cx, 0x1c3) & 0xfu;
if (positionFormat == 0u) {
result.rasterizerDiscard = true;
} else {
Require(positionFormat == 4u, "position export format " + std::to_string(positionFormat) + " is unsupported");
}
for (std::uint32_t index = 0; index < exportCount; ++index) {
const auto slot = exportSlots[index];
if (((targetMask >> (4u * slot)) & 0xfu) == 0) continue;
Expand Down
30 changes: 29 additions & 1 deletion core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,24 @@ void stateTests() {
Require(state.color.address == reinterpret_cast<std::uintptr_t>(colorMemory.data()) && state.color.bytes == colorMemory.size(), "render-target address or size changed");
Require(state.viewport.y == 4 && state.viewport.height == -4, "negative viewport height was lost");
Require(state.color.format == VK_FORMAT_R8G8B8A8_UNORM, "RGBA format changed");
Require(!state.rasterizerDiscard, "a four-component position export discarded rasterization");
queue.context[0x1b3] = 2;
queue.context[0x1b4] = 2;
queue.context[0x1c3] = 0;
state = AgcDriver::Graphics::DecodeState(queue);
Require(state.rasterizerDiscard, "a disabled position export did not discard rasterization");
Require(AgcDriver::Graphics::DrawRejection(queue, false).empty(), "a draw without a position export was rejected");
queue.context[0x1c3] = 0x44;
Require(!AgcDriver::Graphics::DecodeState(queue).rasterizerDiscard, "an auxiliary position export discarded rasterization");
queue.context[0x1c3] = 1;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "position export format 1");
queue.context[0x1c3] = 2;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "position export format 2");
queue.context[0x1c3] = 3;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "position export format 3");
queue = makeState();
queue.context[0x1c3] = 0;
Require(AgcDriver::Graphics::CanonicalPipelineState(AgcDriver::Graphics::DecodeState(queue)).rasterizerDiscard, "the canonical state dropped the rasterizer discard");
queue.userConfig[0x24b] = 1;
queue.context[0x1b3] = 2;
queue.context[0x1b4] = 2;
Expand Down Expand Up @@ -8205,6 +8223,7 @@ struct ModuleShape {
bool layerOutput = false;
bool terminateInvocation = false;
bool omitTerminateExtension = false;
bool noPosition = false;
};

void emit(std::vector<std::uint32_t>& out, spv::Op op, std::initializer_list<std::uint32_t> operands) {
Expand Down Expand Up @@ -8354,7 +8373,7 @@ std::vector<std::uint32_t> makeModule(const ModuleShape& shape) {
emit(declarations, spv::OpVariable, {inputPointer, input, spv::StorageClassInput});
emit(annotations, spv::OpDecorate, {input, spv::DecorationLocation, 0});
}
if (shape.fragment) emit(annotations, spv::OpDecorate, {output, spv::DecorationLocation, 0});
if (shape.fragment || shape.noPosition) emit(annotations, spv::OpDecorate, {output, spv::DecorationLocation, 0});
else emit(annotations, spv::OpDecorate, {output, spv::DecorationBuiltIn, spv::BuiltInPosition});
if (shape.push) {
const auto length = id();
Expand Down Expand Up @@ -9329,6 +9348,15 @@ void barycentricEmulationTests() {
expectFailure([&] { ValidateShaders(shaders, state, subgroup, false, false, false, true); }, "triangle primitives");
state.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
ValidateShaders(shaders, state, subgroup, false, false, false, true);
RecompileResult withoutPosition;
withoutPosition.spirv = makeModule({.noPosition = true});
RecompileResult plainPixel;
plainPixel.spirv = makeModule({.fragment = true});
const std::array<CompiledShader, 2> withoutPositionShaders{{{ShaderStage::Vertex, &withoutPosition, 0}, {ShaderStage::Fragment, &plainPixel, 0}}};
expectFailure([&] { ValidateShaders(withoutPositionShaders, state, subgroup, false, false, false, true); }, "vertex shader does not export position");
auto discarded = state;
discarded.rasterizerDiscard = true;
ValidateShaders(withoutPositionShaders, discarded, subgroup, false, false, false, true);
const auto plain = compile(interpolates, false);
const std::array<CompiledShader, 3> plainShaders{{{ShaderStage::Vertex, &vertex, 0}, {ShaderStage::Geometry, &geometry, 0}, {ShaderStage::Fragment, &plain, 0}}};
expectFailure([&] { ValidateShaders(plainShaders, state, subgroup, false, false, false, true); }, "only for emulated barycentrics");
Expand Down
2 changes: 2 additions & 0 deletions docs/dev/debt/libSceAgcDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@
- [Device-lost fault attribution](../../../core/libs/prx/libSceAgcDriver/Execution/include/DeviceFault.hpp) (libSceAgcDriver): a device loss prints the faulting VA with its guest snapshot (owner or neighbours), a bracket window (last completed, in flight, first not started, last 8 tokens) and draw/dispatch tokens (serial, program, variant, desc). Find returns the entry by value (acquire-load, copy, acquire-reload); Claim clears the slot first so a reused token misses instead of aliasing (reuse test). Draws emit their token through the NV checkpoint backend (emission test); serial falls back to the checkpoint marker. Queues report separately with role and queue id; live resources copy under a mutex. Needs APS5_GPU_CHECKPOINTS; the marker buffer stays AMD-only, NVIDIA is draw-only. Cannot name T# or pending write-back. Vendor dump via APS5_DUMP_DEVICE_FAULT where supported. Opened for PPSA01342 (#10634): second-world load faults a write with no checkpoint reached.
- [sceAgcSdmaClose, sceAgcSdmaConstFill, sceAgcSdmaCopyLinear, sceAgcSdmaCopyTiledBC, sceAgcSdmaCopyTiledGen2, sceAgcSdmaCopyWindowBC, sceAgcSdmaCopyWindowGen2, sceAgcSdmaFlush, sceAgcSdmaOpen, sceAgcSdmaSetTileModesBC](../../../core/libs/prx/libSceAgcDriver/Export.cpp) (libSceAgcDriver) - names and NIDs are present in the [PS5 3.20 export inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceAgcDriver.c) and the [verified NID name database](https://github.com/zecoxao/sce_symbols/blob/2883963a0a514ba6e77407a08ef4730a65e88254/aerolib.csv); they are declared without parameters and throw through `NotImplemented_nid_no_patch`. The sibling [libSceSdma](../../../core/libs/prx/libSceSdma/Export.cpp) exports the same operations under different `sceSdma*` NIDs, but the driver-level prototypes, handle layout and behavior are unknown; this is not an ABI claim.

- [SPI_SHADER_POS_FORMAT without a position export](../../../core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp) (libSceAgcDriver) - a `POS0` entry of 0 (`SPI_SHADER_ZERO`) is decoded as a draw that rasterizes nothing and sets `rasterizerDiscardEnable`. That follows the register name; no console measurement shows the hardware discards the primitives rather than faulting or rasterizing an undefined position, and Mesa only programs `POS0` as four components. Other `POS0` formats than 0 and 4 stop the title.

### Opt-in draw paths

- [Draw finisher](../../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp) (`APS5_DRAW_PIPELINE`) - opt-in. The Linux main-image page table it adds matches what Windows already does by default.
Expand Down
Loading