Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6e5e221
feat(agc): hashed device image key table
slopezjur Nov 13, 2026
2e37e66
feat(agc): bindless image descriptor heap
slopezjur Nov 13, 2026
cc339b4
feat(agc): serve sampled table images of compute shaders from the bin…
slopezjur Nov 13, 2026
02b8c9c
feat(agc): read graphics-stage image tables through the bindless heap
slopezjur Nov 13, 2026
86ae371
docs(agc): document the bindless image switches
slopezjur Nov 13, 2026
7270539
test(agc): run the image table test through the bindless heap
slopezjur Nov 14, 2026
4259de4
fix(shader): encode a table column's dynamic flag where the plan deco…
slopezjur Nov 15, 2026
2815522
fix(agc): bound the texture service's refusal details
slopezjur Nov 15, 2026
6d74113
test(agc): cover table S#s, heap lowering and runtime-address T#s
slopezjur Nov 15, 2026
bd85474
docs(agc): move the bindless heap debt entry into a fragment
slopezjur Nov 15, 2026
b8ff7af
fix(shader): update the Linux layout guards for the bindless cache fi…
slopezjur Nov 17, 2026
0752d38
test(agc): drop the unreachable heap-off branch of the runtime-addres…
slopezjur Nov 17, 2026
821c5bf
fix(agc): keep bindless miss-ring stores out of the guest address sto…
slopezjur Nov 17, 2026
11eb605
test(agc): cover materialization through both image-table ABIs
Scramblrrrr Nov 17, 2026
27ff3b9
test(agc): report the heap skip of the bindless images test
slopezjur Nov 17, 2026
a717529
fix(agc): refuse the bindless present wait under the GPU lock
slopezjur Nov 17, 2026
8be43d3
test(agc): pin the emitted miss-ring stores against the guest store scan
slopezjur Nov 21, 2026
1bcda8e
fix(shader): refuse runtime descriptor addresses on images the heap d…
slopezjur Nov 22, 2026
ef069fd
fix(agc): don't replay bindless pipelines without the heap
slopezjur Nov 22, 2026
73f32d9
test(agc): run a split-state program that reads the bindless heap
slopezjur Nov 22, 2026
21dd642
docs(agc): record the heap's set requirement and exact-mode budget
slopezjur Nov 22, 2026
503eef7
test(agc): accept the heap binding shape in the thread-dimension case
slopezjur Nov 22, 2026
f8ed05a
chore(agc): merge upstream main into the bindless heap
17bryen Dec 1, 2026
50d8b4a
fix(agc): refuse heap entries whose base address is not mapped
17bryen Dec 1, 2026
1fbdd63
fix(shader): give image interfaces that differ in any compared field …
17bryen Dec 1, 2026
e4d22e8
fix(agc): re-check the resident key a heap record is rewritten to
17bryen Dec 1, 2026
710b82f
fix(agc): keep a heap entry until its replacement is placed
17bryen Dec 1, 2026
8617e2f
fix(agc): read a heap table again once its unmapped memory is mapped
17bryen Dec 1, 2026
f95cb45
fix(agc): keep a wrapped probe cluster when the heap key table is reb…
17bryen Dec 1, 2026
042c7dd
fix(agc): keep bindless heap dispatches out of overlapped dispatch runs
17bryen Nov 30, 2026
3813b12
fix(agc): print the bindless frame line after releasing the GPU mutex
17bryen Dec 1, 2026
14c6ec7
fix(agc): read APS5_BINDLESS_STATS the same way in the heap resolver
17bryen Dec 1, 2026
eb65469
style(shader): drop an unused include from the image emitter
17bryen Dec 1, 2026
fdd73fa
docs(agc): record the bindless heap's known gaps
17bryen Dec 1, 2026
5eddef5
chore(agc): merge upstream main into the bindless heap
17bryen Dec 2, 2026
500e8ad
fix(agc): stop a replaced device's texture service worker
17bryen Dec 2, 2026
4fdb086
fix(agc): refresh a heap entry per use when a re-prove makes it per-use
17bryen Dec 2, 2026
6d2246a
fix(agc): serve 1D reads of 1D arrays and depth-compare 1D surfaces f…
17bryen Dec 2, 2026
560f07b
test(agc): make the bindless table test's dispatch writes visible bef…
17bryen Dec 2, 2026
4024954
test(agc): pick the best adapter that supports the bindless heap in t…
17bryen Dec 2, 2026
251f96d
test(agc): order back-to-back heap test dispatches that write the sam…
17bryen Dec 2, 2026
109a1ff
fix(shader): give lanes the wave-uniform heap probe skips a miss, not…
17bryen Dec 2, 2026
cd9ca80
fix(shader): give a heap quad's fallback lanes the chosen lane's imag…
17bryen Dec 2, 2026
e6b5e49
fix(agc): republish the heap key table after a batch's submit is disc…
17bryen Dec 2, 2026
f79f762
test(agc): skip the heap flag-on test on a device that cannot host th…
17bryen Dec 2, 2026
8f7d6e4
build(agc): give the generated heap lookup shader header one owning t…
17bryen Dec 2, 2026
959850e
fix(shader): treat an invalid sampler table entry as a heap miss
17bryen Dec 2, 2026
575116e
perf(agc): register the heap table's discard action once per batch
17bryen Dec 2, 2026
fba486f
fix(shader): record a heap pointer-chain fault only for the image ins…
17bryen Dec 2, 2026
a394283
docs(agc): bring the bindless heap gaps entry up to date
17bryen Dec 2, 2026
7beca39
fix(agc): fit the bindless heap's descriptor pool to the device's upd…
17bryen Dec 2, 2026
15ef825
fix(shader): keep an image paired with a nested sampler table on per-…
17bryen Dec 2, 2026
3ab766e
fix(agc): leave room in the heap's descriptor limits for a stage's ow…
17bryen Dec 2, 2026
6d08e46
docs(agc): record that a heap worker commit between two draws splits …
17bryen Dec 2, 2026
a3a4c7a
test(agc): pin the per-draw table tests and the heap tests against a …
17bryen 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
7 changes: 6 additions & 1 deletion core/libs/prx/libSceAgcDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ set(agcDriverSources
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/Screenshot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/Draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/DepthSurface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/DeviceImageKeys.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/DescriptorHeap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/BindlessTable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/TextureService.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/BindlessResolvers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/MultisampleTarget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/FirstSampleCopy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/src/ColorTargetLayout.cpp
Expand Down Expand Up @@ -1193,7 +1198,7 @@ endif()

if(BUILD_TESTING)
get_directory_property(agcRegisteredTests TESTS)
list(FILTER agcRegisteredTests EXCLUDE REGEX "^(agc_pipeline_journal(_long_paths|_extended_paths)?|agc_driver_pipeline_journal(_undecodable_module)?|agc_pipeline_store_replay_growth|agc_pipeline_journal_replay_priority)$")
list(FILTER agcRegisteredTests EXCLUDE REGEX "^(agc_pipeline_journal(_long_paths|_extended_paths)?|agc_driver_pipeline_journal(_undecodable_module|_bindless_switch)?|agc_pipeline_store_replay_growth|agc_pipeline_journal_replay_priority)$")
set_property(TEST ${agcRegisteredTests} APPEND PROPERTY ENVIRONMENT "APS5_NO_PIPELINE_JOURNAL=1")
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace AgcDriver {

namespace Graphics {
class StorageTexture;
class TextureService;
struct HtileMaskClear;
}

Expand Down Expand Up @@ -88,6 +89,12 @@ class VulkanDevice {
VulkanDevice(const VulkanDevice&) = delete;
VulkanDevice& operator=(const VulkanDevice&) = delete;
std::string DeviceName() const;
bool BindlessImagesEnabled() const;
const std::string& BindlessUnsupportedReason() const;
bool TextureServiceRunning() const;
const Graphics::TextureService* BindlessService() const;
void BindlessPresentWait();
void PrimeBindlessDraw(std::span<const std::shared_ptr<const ShaderRecompiler::RecompileResult>> programs) const;
std::string DriverInfo() const;
VkDriverId DriverId() const;
bool SupportsImageFormat(VkFormat format, VkImageUsageFlags usage) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ DrawVerdict Driver::finishDraw(DrawTail& tail, PerformanceTimer& timing) {
for (const auto& region : memory) snapshots.push_back({region.guestAddress, region.bytes});
};
snapshot();
localDevice->PrimeBindlessDraw(compiledStages);
timing.Mark("post_compile_prepare");
const auto lockForDraw = [&] {
require(tail.queue != nullptr, "the draw finisher reached a draw it cannot commit through the pipeline");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ void Driver::Present(const PresentationWindow& window, const DisplayBuffer* buff
std::shared_ptr<VulkanDevice> presenting;
timing.Mark("validate");
try {
if (const auto bindless = device.Load(); bindless != nullptr && bindless->TextureServiceRunning()) {
bindless->BindlessPresentWait();
timing.Mark("bindless_wait");
}
bool submitted = false;
bool presentable = false;
bool trailing = false;
Expand Down
135 changes: 133 additions & 2 deletions core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace AgcDriver::Graphics {
bool LoopGuardTripped();

struct BdaFaultChunk;
class TextureService;

class BdaResources {
public:
Expand Down Expand Up @@ -94,6 +95,7 @@ class BdaResources {
std::shared_ptr<BdaFaultChunk> faultChunk;
VkDeviceSize faultOffset = 0;
bool reportOnly = false;
const TextureService* textureService = nullptr;
std::uint64_t lastUse = 0;
bool privateSlot = false;
mutable std::unique_ptr<Buffer> pages;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_BINDLESSRESOLVERS_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_BINDLESSRESOLVERS_HPP

#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureService.hpp"
#include <cstdint>
#include <functional>
#include <memory>

namespace ShaderRecompiler {
struct BindlessInterface;
}

namespace AgcDriver::Graphics {

class GuestBindlessMemory final : public BindlessMemory {
public:
bool Read(std::uint64_t address, std::span<std::uint32_t> words) override;
std::uint64_t Collect(std::uint64_t address, std::size_t bytes) override;
bool Unchanged(std::uint64_t address, std::size_t bytes, std::uint64_t generation) override;
std::uint64_t MappingSerial() override;
bool Mapped(std::uint64_t address, std::size_t bytes) override;
};

class DriverBindlessResolver final : public BindlessResolver {
public:
using InterfaceLookup = std::function<std::shared_ptr<const ShaderRecompiler::BindlessInterface>(std::uint64_t)>;
explicit DriverBindlessResolver(const Context& context, InterfaceLookup lookup = {});
BindlessPrepared Prepare(const DeviceImageKeys::Key& key) override;
BindlessResolution Commit(const BindlessPrepared& prepared) override;
bool Current(const BindlessResolution& resolution) override;
bool RefreshGeneration(BindlessPrepared& prepared) override;

private:
Context context;
InterfaceLookup lookup;
};

}

#endif
113 changes: 113 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/BindlessTable.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_BINDLESSTABLE_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_BINDLESSTABLE_HPP

#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DescriptorHeap.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DeviceImageKeys.hpp"
#include <cstdint>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <vector>

namespace AgcDriver::Graphics {

class Buffer;
class Recorder;

bool BindlessImagesRequested();

struct BindlessFeatureSupport {
bool bufferDeviceAddress = false;
bool nullDescriptor = false;
bool runtimeDescriptorArray = false;
bool partiallyBound = false;
bool sampledNonUniform = false;
bool storageNonUniform = false;
bool sampledUpdateAfterBind = false;
bool storageUpdateAfterBind = false;
bool updateUnusedWhilePending = false;
std::uint32_t boundDescriptorSets = 0;
};

std::optional<std::string> BindlessUnsupported(const BindlessFeatureSupport& support);
std::uint32_t BindlessRingRecords();

class BindlessTable {
public:
using Key = DeviceImageKeys::Key;
static constexpr std::uint32_t DefaultRingCapacity = 65536u;
static constexpr std::uint32_t MinSeenSlots = 1u << 22u;

BindlessTable(const Context& context, DescriptorHeap::Capacities capacities, std::uint32_t buckets = DeviceImageKeys::InitialBuckets, std::uint32_t maxBuckets = DeviceImageKeys::MaxBuckets, std::uint32_t ringCapacity = DefaultRingCapacity);
~BindlessTable();
BindlessTable(const BindlessTable&) = delete;
BindlessTable& operator=(const BindlessTable&) = delete;

DescriptorHeap& Heap() { return heap; }
std::uint64_t HeaderAddress() const;
DeviceImageKeys::Insertion Insert(const Key& key, const DeviceImageValue& value);
std::optional<DeviceImageValue> Find(const Key& key) const;
std::uint32_t Retire(const std::function<bool(const Key&, const DeviceImageValue&)>& drop);
void Publish(Recorder& recorder);
std::vector<DeviceImageMiss> TakeMisses();
std::shared_ptr<void> HoldRing();
void ForgetReportedMisses();
std::uint32_t RingCapacity() const { return ringCapacity; }
std::uint32_t SeenSlots() const { return seenSlots; }

struct Counts {
std::uint64_t publications = 0;
std::uint64_t bucketUpdates = 0;
std::uint64_t uploads = 0;
std::uint64_t rings = 0;
std::uint64_t drained = 0;
std::uint64_t misses = 0;
std::uint64_t dropped = 0;
std::uint64_t retired = 0;
std::uint64_t seenClears = 0;
std::uint32_t entries = 0;
std::uint32_t buckets = 0;
};
Counts Totals() const;

private:
struct Rings {
std::mutex mutex;
std::vector<std::shared_ptr<Buffer>> free;
std::vector<DeviceImageMiss> misses;
std::uint64_t drained = 0;
std::uint64_t written = 0;
std::uint64_t dropped = 0;
std::map<const Buffer*, std::uint32_t> holds;
std::vector<std::shared_ptr<Buffer>> deferred;
std::uint32_t capacity = 0;
bool clearSeen = true;
};
static void drain(const std::shared_ptr<Rings>& rings, const std::shared_ptr<Buffer>& ring);
static void release(const std::shared_ptr<Rings>& rings, const std::shared_ptr<Buffer>& ring);

Context context;
DescriptorHeap heap;
mutable std::mutex mutex;
DeviceImageKeys keys;
std::shared_ptr<Buffer> header;
std::shared_ptr<Buffer> table;
std::uint32_t tableBuckets = 0;
std::uint32_t ringCapacity = 0;
std::uint32_t seenSlots = 0;
std::shared_ptr<Buffer> seen;
std::shared_ptr<Buffer> ring;
std::uint64_t ringBatch = 0;
bool republish = false;
std::uint64_t discardBatch = 0;
std::shared_ptr<Rings> rings;
Counts totals;
};

}

#endif
4 changes: 4 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class GraphicsPipelineCache;
class Recorder;
class CommandState;
class DescriptorCache;
class BindlessTable;
class TextureService;
class SamplerCache;
class ShaderResources;
class PlaceholderImages;
Expand Down Expand Up @@ -329,6 +331,8 @@ struct Context {
bool bufferInt64Atomics = false;
VkDeviceAddress atomicLockTable = 0;
const PlaceholderImages* placeholderImages = nullptr;
BindlessTable* bindlessTable = nullptr;
TextureService* textureService = nullptr;
bool viewportIndexLayer = false;
bool demoteToHelperInvocation = false;
bool earlyFragmentSampleMaskTestBeforeSampleCounting = false;
Expand Down
89 changes: 89 additions & 0 deletions core/libs/prx/libSceAgcDriver/Graphics/include/DescriptorHeap.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_DESCRIPTORHEAP_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_DESCRIPTORHEAP_HPP

#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include <array>
#include <cstdint>
#include <deque>
#include <mutex>
#include <optional>
#include <string>
#include <vector>

namespace AgcDriver::Graphics {

class DescriptorHeap {
public:
static constexpr std::uint32_t MaxViews = 16u;
enum class Array : std::uint32_t { Samplers, SampledImages, StorageImages, Count };
struct Capacities {
std::uint32_t samplers;
std::uint32_t sampledImages;
std::uint32_t storageImages;
};
struct StageReservation {
std::uint64_t samplers;
std::uint64_t sampledImages;
std::uint64_t storageImages;
};

DescriptorHeap(const Context& context, Capacities capacities);
~DescriptorHeap();
DescriptorHeap(const DescriptorHeap&) = delete;
DescriptorHeap& operator=(const DescriptorHeap&) = delete;

static Capacities DeviceCapacities(const Context& context);
static StageReservation PerDrawReservation(const Context& context);
static std::optional<std::string> Unfit(const Capacities& capacities);
VkDescriptorSetLayout Layout(VkShaderStageFlags stages);
VkDescriptorSetLayout EmptyLayout();
void SetHeader(VkBuffer buffer, VkDeviceSize bytes);
VkDescriptorSet Set(VkShaderStageFlags stages);
std::uint32_t Capacity(Array array) const { return arrays[static_cast<std::size_t>(array)].capacity; }
std::uint32_t AllocateSampler(VkSampler sampler);
std::uint32_t AllocateImage(Array array, VkImageView view, VkImageLayout layout);
void Release(Array array, std::uint32_t slot, std::uint64_t retireSerial);
std::uint32_t Collect(std::uint64_t completedSerial);
bool Live(Array array, std::uint32_t slot) const;
std::uint32_t LiveSlots(Array array) const;
std::uint32_t PendingReleases() const;
void Bind(VkCommandBuffer commands, VkPipelineBindPoint bindPoint, VkPipelineLayout pipelineLayout, VkShaderStageFlags stages);

private:
struct View {
VkShaderStageFlags stages;
VkDescriptorSetLayout layout;
VkDescriptorSet set;
};
struct Retired {
std::uint32_t slot;
std::uint64_t serial;
};
struct Slots {
std::uint32_t capacity = 0;
VkDescriptorType type = VK_DESCRIPTOR_TYPE_SAMPLER;
std::vector<VkDescriptorImageInfo> entries;
std::vector<std::uint32_t> generations;
std::vector<bool> live;
std::vector<std::uint32_t> free;
std::deque<Retired> retired;
};
const View& view(VkShaderStageFlags stages);
std::uint32_t allocate(Array array, const VkDescriptorImageInfo& entry);
void write(const View& target, Array array, std::uint32_t first, std::uint32_t count);
void writeHeader(const View& target);
void release() noexcept;

Context context;
VkDescriptorPool pool = VK_NULL_HANDLE;
VkSampler nullSampler = VK_NULL_HANDLE;
VkDescriptorSetLayout emptyLayout = VK_NULL_HANDLE;
VkDescriptorBufferInfo header{VK_NULL_HANDLE, 0, 0};
mutable std::mutex mutex;
std::deque<View> views;
std::array<Slots, static_cast<std::size_t>(Array::Count)> arrays;
};

}

#endif
Loading
Loading