Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ab69603
fix(agc): support 4_4_4_4 component orders during PPSA38500 loading
lgqdaxia Nov 27, 2026
fc78d6b
fix(agc): check written alpha before bypassing 4_4_4_4 blending
lgqdaxia Nov 27, 2026
e2e9788
fix(agc): allow 4_4_4_4 replacement on written channels
lgqdaxia Nov 27, 2026
3545f05
Merge component-order prerequisite from #27966
lgqdaxia Nov 29, 2026
679192f
fix(agc): blend packed 4_4_4_4 color during PPSA38500 scene loading
lgqdaxia Nov 29, 2026
cf85304
Merge current main before publishing the RGBA4 blend follow-up
lgqdaxia Nov 29, 2026
a522cba
fix(agc): render DCC-compressed 4_4_4_4 unorm color targets
zeezey Nov 29, 2026
9f73b66
test(agc): cover more DCC 4_4_4_4 target clears and the mip refusal
zeezey Nov 29, 2026
ad224f3
Merge DCC 4_4_4_4 fast clears from #28311
zeezey Nov 30, 2026
3b32aa0
fix(agc): keep DCC keys in the merge descriptor of a color target
zeezey Nov 29, 2026
2d889db
test(agc): cover more merges into DCC targets and DCC keys in texture…
zeezey Nov 30, 2026
0a364b3
Merge current main under the occlusion count follow-up
zeezey Nov 30, 2026
f1634cf
fix(agc): count the samples of merging draws that kill under late tests
zeezey Nov 29, 2026
9884d16
fix(agc): drop the count start of a discarded batch
zeezey Dec 2, 2026
c078f50
fix(agc): count only surviving, non-helper invocations of a merging draw
zeezey Dec 2, 2026
e707352
fix(agc): refuse a multisampled killing merge while samples are counted
zeezey Dec 2, 2026
22f2bcf
fix(agc): refuse a killing merge to a multi-coverage target while sam…
zeezey Dec 2, 2026
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 @@ -1055,7 +1055,7 @@ DrawVerdict Driver::finishDraw(DrawTail& tail, PerformanceTimer& timing) {
}
try {
require(result.pushConstants.size() <= pushBudget, "stage push constants exceed the pipeline push constant block");
stages.push_back({program.binary.stage, &result, result.pushConstants.empty() ? 0u : pushCursorBytes, stageCaptures[i].registeredViews.get()});
stages.push_back({program.binary.stage, &result, result.pushConstants.empty() ? 0u : pushCursorBytes, stageCaptures[i].registeredViews.get(), program.binary.codeAddress});
pushCursorBytes += static_cast<std::uint32_t>(result.pushConstants.size());
} catch (...) {
TraceMaterializationFailure(trace.token, submission, packetOffset, "push-constant-validation", completedSubdraws, std::current_exception());
Expand Down
8 changes: 8 additions & 0 deletions core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ struct VulkanDevice::State {
std::unique_ptr<Graphics::Buffer> emptyBuffer;
std::unique_ptr<Graphics::Buffer> oversizedBuffer;
std::unique_ptr<Graphics::Buffer> atomicLockTable;
std::unique_ptr<Graphics::Buffer> shaderSampleCounter;
std::unique_ptr<Graphics::PlaceholderImages> placeholderImages;
std::unique_ptr<Graphics::TextureCache> textureCache;
std::unique_ptr<Graphics::PipelineCache> pipelineCache;
Expand Down Expand Up @@ -1304,6 +1305,7 @@ struct VulkanDevice::State {
emptyBuffer.reset();
oversizedBuffer.reset();
atomicLockTable.reset();
shaderSampleCounter.reset();
placeholderImages.reset();
samplerCache.reset();
textureCache.reset();
Expand Down Expand Up @@ -2855,6 +2857,11 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
const auto words = state->atomicLockTable->Bytes();
std::memset(words.data(), 0, words.size());
}
if (graphicsContext().bufferDeviceAddress) {
state->shaderSampleCounter = std::make_unique<Graphics::Buffer>(graphicsContext(), sizeof(std::uint64_t), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
const auto words = state->shaderSampleCounter->Bytes();
std::memset(words.data(), 0, words.size());
}
static const bool headlessPipelineCache = std::getenv("APS5_HEADLESS_PIPELINE_CACHE") != nullptr;
state->pipelineCache = std::make_unique<Graphics::PipelineCache>(graphicsContext(), state->properties, window != nullptr || compileOnly || headlessPipelineCache);
if (!compileOnly) {
Expand Down Expand Up @@ -5275,6 +5282,7 @@ Graphics::Context VulkanDevice::buildContext() const {
context.nullDescriptors = state->shaderProfile != nullptr && state->shaderProfile->NullDescriptors();
context.bufferInt64Atomics = state->bufferInt64Atomics;
context.atomicLockTable = state->atomicLockTable ? state->atomicLockTable->DeviceAddress() : 0;
context.shaderSampleCounter = state->shaderSampleCounter.get();
context.placeholderImages = state->placeholderImages.get();
context.viewportIndexLayer = state->viewportIndexLayer;
context.imageFormatList = state->imageFormatList;
Expand Down
2 changes: 2 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
namespace AgcDriver::Graphics {


class Buffer;
class TextureDetiler;
class GpuColorTransfer;
class BufferPool;
Expand Down Expand Up @@ -328,6 +329,7 @@ struct Context {
bool nullDescriptors = false;
bool bufferInt64Atomics = false;
VkDeviceAddress atomicLockTable = 0;
Buffer* shaderSampleCounter = nullptr;
const PlaceholderImages* placeholderImages = nullptr;
bool viewportIndexLayer = false;
bool demoteToHelperInvocation = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class PipelineSpecialization {
}
}

PipelineSpecialization(const ShaderRecompiler::RecompileResult& shader, VkDeviceAddress atomicLockTable, std::uint32_t layerBase, std::uint32_t layerCount) : PipelineSpecialization(shader, atomicLockTable) {
PipelineSpecialization(const ShaderRecompiler::RecompileResult& shader, VkDeviceAddress atomicLockTable, VkDeviceAddress sampleCounter, std::uint32_t layerBase, std::uint32_t layerCount) : PipelineSpecialization(shader, atomicLockTable) {
for (auto& constant : values) {
if (constant.id == ShaderRecompiler::PipelineSpecialization::MeshLayerBase) constant.value = layerBase;
if (constant.id == ShaderRecompiler::PipelineSpecialization::MeshLayerCount) constant.value = layerCount;
if (ShaderRecompiler::PipelineSpecialization::IsSampleCounter(constant.id)) constant.value = static_cast<std::uint32_t>(sampleCounter >> (32u * (constant.id - ShaderRecompiler::PipelineSpecialization::SampleCounterBase)));
}
}

Expand Down
16 changes: 16 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ class Recorder {
std::uint64_t SamplesTotal();
bool DumpSamples(VkDeviceAddress target, std::uint64_t address = 0, std::uint32_t blocks = 0xffffu);
void NoteSampledDraw(VkCommandBuffer commands);
void NoteShaderCountedDraw(VkCommandBuffer commands, std::uint64_t program = 0);
bool CountsShaderSamples() const;
void NoteDrawTraceToken(std::uint64_t token) noexcept;
void NoteFaultToken(AgcDriver::FaultToken token) noexcept;
bool QueuesSampleDumps() const;
Expand Down Expand Up @@ -574,6 +576,7 @@ class Recorder {
// The function the flush hook calls, on the accessing thread (which may hold the GPU mutex),
// when an access overlaps one of that thread's queued labels; it records them. Set once.
static void SetQueuedLabelRecorder(void (*recorder)());
static void RefuseGpuSampleCounterForTest(bool refuse);
static void FailNextSubmitsForTest(unsigned count);
static void FailNextDiscardRegistrationsForTest(unsigned count);
// Whether the lock-free pending-write snapshot (open, in-flight and finishing batches) overlaps
Expand Down Expand Up @@ -793,6 +796,7 @@ class Recorder {
VkQueryPool handle;
std::uint32_t slot = 0;
std::uint64_t batch = 0;
VkBuffer counted = VK_NULL_HANDLE;
};
static_assert(std::is_nothrow_move_constructible_v<SampleSegment> && std::is_nothrow_move_assignable_v<SampleSegment>);
struct Batch {
Expand Down Expand Up @@ -849,6 +853,8 @@ class Recorder {
std::uint32_t segmentNext = 0;
std::uint32_t segmentSlot = 0;
bool segmentActive = false;
bool shaderSamples = false;
bool countingStarted = false;
std::uint32_t queuedDumps = 0;
std::vector<std::uint64_t> timedKeys;
std::vector<std::uint64_t> timedBytes;
Expand Down Expand Up @@ -979,9 +985,19 @@ class Recorder {
void foldSegments();
void foldQueuedDumps(VkCommandBuffer commands, std::span<const Batch::StoreRun::Queued> writes, std::size_t first, std::size_t end, std::uint32_t& dumpIndex, std::uint32_t& consumed);
void reserveSampleRestore(const Batch& batch);
void startCounting();
void settleShaderSamples();
void copySegment(VkCommandBuffer commands, const SampleSegment& segment, std::uint32_t index, std::uint32_t run = 1);
std::uint64_t segmentSamples(const SampleSegment& segment);
void traceShaderSamples(std::uint64_t dump, VkDeviceAddress target, std::uint64_t address, std::uint32_t blocks, std::size_t first);
std::vector<SampleSegment> pendingSamples;
std::uint64_t sampleBatches = 0;
bool countingSamples = false;
bool shaderSamplesDirty = false;
std::shared_ptr<Buffer> shaderSlots;
std::uint32_t shaderSlotNext = 0;
std::uint64_t sampleDumps = 0;
std::vector<std::uint64_t> shaderCountedPrograms;
int meshArgumentState = 0;
VkPipelineLayout meshArgumentLayout = VK_NULL_HANDLE;
VkPipeline meshArgumentPipeline = VK_NULL_HANDLE;
Expand Down
7 changes: 7 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/Shaders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct CompiledShader {
const ShaderRecompiler::RecompileResult* program;
std::uint32_t pushConstantOffset;
const std::vector<ShaderRecompiler::RegisteredImageView>* registeredImageViews = nullptr;
std::uint64_t codeAddress = 0;
};

inline std::uint32_t KeyedPushOffset(const CompiledShader& shader) {
Expand Down Expand Up @@ -97,6 +98,12 @@ inline VkShaderStageFlags PushConstantStages(std::span<const CompiledShader> sha
return result;
}

inline bool ShadersCountSamples(std::span<const CompiledShader> shaders) {
return std::ranges::any_of(shaders, [](const CompiledShader& shader) {
return shader.stage == ShaderRecompiler::ShaderStage::Fragment && shader.program != nullptr && std::ranges::any_of(shader.program->specialization, [](const ShaderRecompiler::PipelineSpecializationConstant& constant) { return ShaderRecompiler::PipelineSpecialization::IsSampleCounter(constant.id); });
});
}

inline std::array<std::byte, PipelinePushConstantBytes> AssemblePushConstants(std::span<const CompiledShader> shaders) {
static_assert(PipelinePushConstantBytes % 4 == 0 && PipelinePushConstantBytes / 4 <= 64 && PipelinePushSlotBytes / 4 < 64, "the occupied mask holds one bit per DWORD of the block");
std::array<std::byte, PipelinePushConstantBytes> result{};
Expand Down
5 changes: 5 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ struct ColorTarget {
std::uint16_t stagedMask = 0;
VkFormat stagedFormat = VK_FORMAT_UNDEFINED;

bool UnclampedBlend() const {
return packing == ShaderRecompiler::ColorExportPacking::None && partialWriteMask == UnclampedBlendMask;
}

bool operator==(const ColorTarget& other) const {
return address == other.address && extent.width == other.extent.width && extent.height == other.extent.height && format == other.format &&
bytes == other.bytes && componentMapping == other.componentMapping && tileMode == other.tileMode && elementBytes == other.elementBytes &&
Expand Down Expand Up @@ -298,6 +302,7 @@ struct ReversedBlend {
ReversedBlend TranslateReversedBlend(std::uint32_t blendControl, std::uint8_t componentMapping, VkFormat format, bool forceDestinationAlphaOne, const std::array<float, 4>& constants);
std::size_t CmaskBytes(std::uint32_t width, std::uint32_t height);
std::uint32_t ColorWriteMask(const Registers& context);
VkFormat ColorTargetDccClearFormat(const ColorTarget& color);
GuestTextureResource SurfaceForTarget(const ColorTarget& color);
GuestTextureResource ArraySurfaceForTarget(const ColorTarget& color);

Expand Down
1 change: 1 addition & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ bool LayoutFor(VkFormat format, Layout& layout) {
case VK_FORMAT_R16G16_SINT: layout = {2, {16, 16}, Kind::Sint}; return true;
case VK_FORMAT_R16G16_SFLOAT: layout = {2, {16, 16}, Kind::Float}; return true;
case VK_FORMAT_B10G11R11_UFLOAT_PACK32: layout = {3, {11, 11, 10}, Kind::Float}; return true;
case VK_FORMAT_R4G4B4A4_UNORM_PACK16: layout = {4, {4, 4, 4, 4}, Kind::Unorm}; return true;
case VK_FORMAT_A2B10G10R10_UNORM_PACK32: case VK_FORMAT_A2R10G10B10_UNORM_PACK32: layout = {4, {10, 10, 10, 2}, Kind::Unorm}; return true;
case VK_FORMAT_A2B10G10R10_UINT_PACK32: layout = {4, {10, 10, 10, 2}, Kind::Uint}; return true;
case VK_FORMAT_R8G8B8A8_UNORM: case VK_FORMAT_R8G8B8A8_SRGB: case VK_FORMAT_B8G8R8A8_UNORM: case VK_FORMAT_B8G8R8A8_SRGB: layout = {4, {8, 8, 8, 8}, Kind::Unorm}; return true;
Expand Down
Loading
Loading