mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Commonise maxwell3d sampler code
This will be shared with the compute engine implementation, the only thing of note with this is that the binding register is now passed as a param since it is part of the compute QMD which can't be dirty tracked.
This commit is contained in:
@ -5,19 +5,24 @@
|
||||
#include <soc/gm20b/gmmu.h>
|
||||
#include "samplers.h"
|
||||
|
||||
namespace skyline::gpu::interconnect::maxwell3d {
|
||||
namespace skyline::gpu::interconnect {
|
||||
void SamplerPoolState::EngineRegisters::DirtyBind(DirtyManager &manager, dirty::Handle handle) const {
|
||||
manager.Bind(handle, samplerBinding, texSamplerPool, texHeaderPool);
|
||||
manager.Bind(handle, texSamplerPool, texHeaderPool);
|
||||
}
|
||||
|
||||
SamplerPoolState::SamplerPoolState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine) : engine{manager, dirtyHandle, engine} {}
|
||||
|
||||
void SamplerPoolState::Flush(InterconnectContext &ctx) {
|
||||
useTexHeaderBinding = engine->samplerBinding.value == engine::SamplerBinding::Value::ViaHeaderBinding;
|
||||
void SamplerPoolState::Flush(InterconnectContext &ctx, bool useTexHeaderBinding) {
|
||||
u32 maximumIndex{useTexHeaderBinding ? engine->texHeaderPool.maximumIndex : engine->texSamplerPool.maximumIndex};
|
||||
auto mapping{ctx.channelCtx.asCtx->gmmu.LookupBlock(engine->texSamplerPool.offset)};
|
||||
|
||||
texSamplers = mapping.first.subspan(mapping.second).cast<TextureSamplerControl>().first(maximumIndex + 1);
|
||||
|
||||
didUseTexHeaderBinding = useTexHeaderBinding;
|
||||
}
|
||||
|
||||
bool SamplerPoolState::Refresh(InterconnectContext &ctx, bool useTexHeaderBinding) {
|
||||
return didUseTexHeaderBinding != useTexHeaderBinding;
|
||||
}
|
||||
|
||||
void SamplerPoolState::PurgeCaches() {
|
||||
@ -26,6 +31,10 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
|
||||
Samplers::Samplers(DirtyManager &manager, const SamplerPoolState::EngineRegisters &engine) : samplerPool{manager, engine} {}
|
||||
|
||||
void Samplers::Update(InterconnectContext &ctx, bool useTexHeaderBinding) {
|
||||
samplerPool.Update(ctx, useTexHeaderBinding);
|
||||
}
|
||||
|
||||
void Samplers::MarkAllDirty() {
|
||||
samplerPool.MarkDirty(true);
|
||||
std::fill(texSamplerCache.begin(), texSamplerCache.end(), nullptr);
|
||||
@ -140,8 +149,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
}
|
||||
|
||||
vk::raii::Sampler *Samplers::GetSampler(InterconnectContext &ctx, u32 samplerIndex, u32 textureIndex) {
|
||||
const auto &samplerPoolObj{samplerPool.UpdateGet(ctx)};
|
||||
u32 index{samplerPoolObj.useTexHeaderBinding ? textureIndex : samplerIndex};
|
||||
const auto &samplerPoolObj{samplerPool.Get()};
|
||||
u32 index{samplerPoolObj.didUseTexHeaderBinding ? textureIndex : samplerIndex};
|
||||
auto texSamplers{samplerPoolObj.texSamplers};
|
||||
if (texSamplers.size() != texSamplerCache.size()) {
|
||||
texSamplerCache.resize(texSamplers.size());
|
@ -7,13 +7,12 @@
|
||||
#include "common.h"
|
||||
#include "tsc.h"
|
||||
|
||||
namespace skyline::gpu::interconnect::maxwell3d {
|
||||
class SamplerPoolState : dirty::CachedManualDirty {
|
||||
namespace skyline::gpu::interconnect {
|
||||
class SamplerPoolState : dirty::CachedManualDirty, dirty::RefreshableManualDirty {
|
||||
public:
|
||||
struct EngineRegisters {
|
||||
const engine::SamplerBinding &samplerBinding;
|
||||
const engine::TexSamplerPool &texSamplerPool;
|
||||
const engine::TexHeaderPool &texHeaderPool;
|
||||
const engine_common::TexSamplerPool &texSamplerPool;
|
||||
const engine_common::TexHeaderPool &texHeaderPool;
|
||||
|
||||
void DirtyBind(DirtyManager &manager, dirty::Handle handle) const;
|
||||
};
|
||||
@ -23,11 +22,13 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
|
||||
public:
|
||||
span<TextureSamplerControl> texSamplers;
|
||||
bool useTexHeaderBinding;
|
||||
bool didUseTexHeaderBinding;
|
||||
|
||||
SamplerPoolState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine);
|
||||
|
||||
void Flush(InterconnectContext &ctx);
|
||||
void Flush(InterconnectContext &ctx, bool useTexHeaderBinding);
|
||||
|
||||
bool Refresh(InterconnectContext &ctx, bool useTexHeaderBinding);
|
||||
|
||||
void PurgeCaches();
|
||||
};
|
||||
@ -42,6 +43,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
public:
|
||||
Samplers(DirtyManager &manager, const SamplerPoolState::EngineRegisters &engine);
|
||||
|
||||
void Update(InterconnectContext &ctx, bool useTexHeaderBinding);
|
||||
|
||||
void MarkAllDirty();
|
||||
|
||||
vk::raii::Sampler *GetSampler(InterconnectContext &ctx, u32 samplerIndex, u32 textureIndex);
|
@ -22,6 +22,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
clearEngineRegisters{registerBundle.clearRegisters},
|
||||
constantBuffers{manager, registerBundle.constantBufferSelectorRegisters},
|
||||
samplers{manager, registerBundle.samplerPoolRegisters},
|
||||
samplerBinding{registerBundle.samplerBinding},
|
||||
textures{manager, registerBundle.texturePoolRegisters},
|
||||
directState{activeState.directState} {
|
||||
ctx.executor.AddFlushCallback([this] {
|
||||
@ -213,6 +214,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
StateUpdateBuilder builder{*ctx.executor.allocator};
|
||||
|
||||
Pipeline *oldPipeline{activeState.GetPipeline()};
|
||||
samplers.Update(ctx, samplerBinding.value == engine::SamplerBinding::Value::ViaHeaderBinding);
|
||||
activeState.Update(ctx, textures, constantBuffers.boundConstantBuffers, builder, indexed, topology, first, count);
|
||||
if (directState.inputAssembly.NeedsQuadConversion()) {
|
||||
count = conversion::quads::GetIndexCount(count);
|
||||
|
@ -4,10 +4,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <gpu/descriptor_allocator.h>
|
||||
#include <gpu/interconnect/common/samplers.h>
|
||||
#include "common.h"
|
||||
#include "active_state.h"
|
||||
#include "constant_buffers.h"
|
||||
#include "samplers.h"
|
||||
#include "textures.h"
|
||||
|
||||
namespace skyline::gpu::interconnect::maxwell3d {
|
||||
@ -35,6 +35,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
ClearEngineRegisters clearRegisters;
|
||||
ConstantBufferSelectorState::EngineRegisters constantBufferSelectorRegisters;
|
||||
SamplerPoolState::EngineRegisters samplerPoolRegisters;
|
||||
const engine::SamplerBinding &samplerBinding;
|
||||
TexturePoolState::EngineRegisters texturePoolRegisters;
|
||||
};
|
||||
|
||||
@ -44,6 +45,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
||||
ClearEngineRegisters clearEngineRegisters;
|
||||
ConstantBuffers constantBuffers;
|
||||
Samplers samplers;
|
||||
const engine::SamplerBinding &samplerBinding;
|
||||
Textures textures;
|
||||
std::shared_ptr<memory::Buffer> quadConversionBuffer{};
|
||||
bool quadConversionBufferAttached{};
|
||||
|
@ -6,10 +6,10 @@
|
||||
#include <tsl/robin_map.h>
|
||||
#include <shader_compiler/frontend/ir/program.h>
|
||||
#include <gpu/cache/graphics_pipeline_cache.h>
|
||||
#include <gpu/interconnect/common/samplers.h>
|
||||
#include "common.h"
|
||||
#include "packed_pipeline_state.h"
|
||||
#include "constant_buffers.h"
|
||||
#include "samplers.h"
|
||||
#include "textures.h"
|
||||
|
||||
namespace skyline::gpu {
|
||||
|
Reference in New Issue
Block a user