mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-25 23:54:15 +01:00
Avoid InterconnectContext use in graphics PipelineManager
We will soon move to a global pipeline manager instance, so it wont be possible to use InterconnectContext at pipeline-creation time anymore
This commit is contained in:
parent
ffe7263848
commit
7dd3a1db0f
@ -173,8 +173,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::array<Pipeline::ShaderStage, engine::ShaderStageCount> MakePipelineShaders(InterconnectContext &ctx, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState) {
|
static std::array<Pipeline::ShaderStage, engine::ShaderStageCount> MakePipelineShaders(GPU &gpu, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState) {
|
||||||
ctx.gpu.shader.ResetPools();
|
gpu.shader.ResetPools();
|
||||||
|
|
||||||
using PipelineStage = engine::Pipeline::Shader::Type;
|
using PipelineStage = engine::Pipeline::Shader::Type;
|
||||||
auto pipelineStage{[](u32 i) { return static_cast<PipelineStage>(i); }};
|
auto pipelineStage{[](u32 i) { return static_cast<PipelineStage>(i); }};
|
||||||
@ -188,7 +188,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto binary{accessor.GetShaderBinary(i)};
|
auto binary{accessor.GetShaderBinary(i)};
|
||||||
auto program{ctx.gpu.shader.ParseGraphicsShader(
|
auto program{gpu.shader.ParseGraphicsShader(
|
||||||
packedState.postVtgShaderAttributeSkipMask,
|
packedState.postVtgShaderAttributeSkipMask,
|
||||||
ConvertCompilerShaderStage(static_cast<PipelineStage>(i)),
|
ConvertCompilerShaderStage(static_cast<PipelineStage>(i)),
|
||||||
binary.binary, binary.baseOffset,
|
binary.binary, binary.baseOffset,
|
||||||
@ -202,7 +202,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
})};
|
})};
|
||||||
if (i == stageIdx(PipelineStage::Vertex) && packedState.shaderHashes[stageIdx(PipelineStage::VertexCullBeforeFetch)]) {
|
if (i == stageIdx(PipelineStage::Vertex) && packedState.shaderHashes[stageIdx(PipelineStage::VertexCullBeforeFetch)]) {
|
||||||
ignoreVertexCullBeforeFetch = true;
|
ignoreVertexCullBeforeFetch = true;
|
||||||
programs[i] = ctx.gpu.shader.CombineVertexShaders(programs[stageIdx(PipelineStage::VertexCullBeforeFetch)], program, binary.binary);
|
programs[i] = gpu.shader.CombineVertexShaders(programs[stageIdx(PipelineStage::VertexCullBeforeFetch)], program, binary.binary);
|
||||||
} else {
|
} else {
|
||||||
programs[i] = program;
|
programs[i] = program;
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto runtimeInfo{MakeRuntimeInfo(packedState, programs[i], lastProgram, hasGeometry)};
|
auto runtimeInfo{MakeRuntimeInfo(packedState, programs[i], lastProgram, hasGeometry)};
|
||||||
shaderStages[i - (i >= 1 ? 1 : 0)] = {ConvertVkShaderStage(pipelineStage(i)), ctx.gpu.shader.CompileShader(runtimeInfo, programs[i], bindings), programs[i].info};
|
shaderStages[i - (i >= 1 ? 1 : 0)] = {ConvertVkShaderStage(pipelineStage(i)), gpu.shader.CompileShader(runtimeInfo, programs[i], bindings), programs[i].info};
|
||||||
|
|
||||||
lastProgram = &programs[i];
|
lastProgram = &programs[i];
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static cache::GraphicsPipelineCache::CompiledPipeline MakeCompiledPipeline(InterconnectContext &ctx,
|
static cache::GraphicsPipelineCache::CompiledPipeline MakeCompiledPipeline(GPU &gpu,
|
||||||
const PackedPipelineState &packedState,
|
const PackedPipelineState &packedState,
|
||||||
const std::array<Pipeline::ShaderStage, engine::ShaderStageCount> &shaderStages,
|
const std::array<Pipeline::ShaderStage, engine::ShaderStageCount> &shaderStages,
|
||||||
span<vk::DescriptorSetLayoutBinding> layoutBindings) {
|
span<vk::DescriptorSetLayoutBinding> layoutBindings) {
|
||||||
@ -448,10 +448,10 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (binding.GetInputRate() == vk::VertexInputRate::eInstance) {
|
if (binding.GetInputRate() == vk::VertexInputRate::eInstance) {
|
||||||
if (!ctx.gpu.traits.supportsVertexAttributeDivisor)
|
if (!gpu.traits.supportsVertexAttributeDivisor)
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
Logger::Warn("Vertex attribute divisor used on guest without host support");
|
Logger::Warn("Vertex attribute divisor used on guest without host support");
|
||||||
else if (!ctx.gpu.traits.supportsVertexAttributeZeroDivisor && binding.divisor == 0)
|
else if (!gpu.traits.supportsVertexAttributeZeroDivisor && binding.divisor == 0)
|
||||||
[[unlikely]]
|
[[unlikely]]
|
||||||
Logger::Warn("Vertex attribute zero divisor used on guest without host support");
|
Logger::Warn("Vertex attribute zero divisor used on guest without host support");
|
||||||
else
|
else
|
||||||
@ -507,7 +507,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
rasterizationCreateInfo.frontFace = packedState.frontFaceClockwise ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise;
|
rasterizationCreateInfo.frontFace = packedState.frontFaceClockwise ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise;
|
||||||
rasterizationCreateInfo.depthBiasEnable = packedState.depthBiasEnable;
|
rasterizationCreateInfo.depthBiasEnable = packedState.depthBiasEnable;
|
||||||
rasterizationCreateInfo.depthClampEnable = packedState.depthClampEnable;
|
rasterizationCreateInfo.depthClampEnable = packedState.depthClampEnable;
|
||||||
if (!ctx.gpu.traits.supportsDepthClamp)
|
if (!gpu.traits.supportsDepthClamp)
|
||||||
Logger::Warn("Depth clamp used on guest without host support");
|
Logger::Warn("Depth clamp used on guest without host support");
|
||||||
rasterizationState.get<vk::PipelineRasterizationProvokingVertexStateCreateInfoEXT>().provokingVertexMode = ConvertProvokingVertex(packedState.provokingVertex);
|
rasterizationState.get<vk::PipelineRasterizationProvokingVertexStateCreateInfoEXT>().provokingVertexMode = ConvertProvokingVertex(packedState.provokingVertex);
|
||||||
|
|
||||||
@ -560,7 +560,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
};
|
};
|
||||||
|
|
||||||
vk::PipelineDynamicStateCreateInfo dynamicState{
|
vk::PipelineDynamicStateCreateInfo dynamicState{
|
||||||
.dynamicStateCount = ctx.gpu.traits.supportsExtendedDynamicState ? ExtendedDynamicStateCount : BaseDynamicStateCount,
|
.dynamicStateCount = gpu.traits.supportsExtendedDynamicState ? ExtendedDynamicStateCount : BaseDynamicStateCount,
|
||||||
.pDynamicStates = dynamicStates.data()
|
.pDynamicStates = dynamicStates.data()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -569,15 +569,15 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
std::array<vk::Viewport, engine::ViewportCount> emptyViewports{};
|
std::array<vk::Viewport, engine::ViewportCount> emptyViewports{};
|
||||||
|
|
||||||
vk::PipelineViewportStateCreateInfo viewportState{
|
vk::PipelineViewportStateCreateInfo viewportState{
|
||||||
.viewportCount = static_cast<u32>(ctx.gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1),
|
.viewportCount = static_cast<u32>(gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1),
|
||||||
.pViewports = emptyViewports.data(),
|
.pViewports = emptyViewports.data(),
|
||||||
.scissorCount = static_cast<u32>(ctx.gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1),
|
.scissorCount = static_cast<u32>(gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1),
|
||||||
.pScissors = emptyScissors.data(),
|
.pScissors = emptyScissors.data(),
|
||||||
};
|
};
|
||||||
|
|
||||||
texture::Format depthStencilFormat{packedState.GetDepthRenderTargetFormat()};
|
texture::Format depthStencilFormat{packedState.GetDepthRenderTargetFormat()};
|
||||||
|
|
||||||
return ctx.gpu.graphicsPipelineCache.GetCompiledPipeline(cache::GraphicsPipelineCache::PipelineState{
|
return gpu.graphicsPipelineCache.GetCompiledPipeline(cache::GraphicsPipelineCache::PipelineState{
|
||||||
.shaderStages = shaderStageInfos,
|
.shaderStages = shaderStageInfos,
|
||||||
.vertexState = vertexInputState,
|
.vertexState = vertexInputState,
|
||||||
.inputAssemblyState = inputAssemblyState,
|
.inputAssemblyState = inputAssemblyState,
|
||||||
@ -594,20 +594,21 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
}, layoutBindings);
|
}, layoutBindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipeline::Pipeline(InterconnectContext &ctx, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState)
|
Pipeline::Pipeline(GPU &gpu, PipelineStateAccessor &accessor, const PackedPipelineState &packedState)
|
||||||
: sourcePackedState{packedState},
|
: sourcePackedState{packedState},
|
||||||
shaderStages{MakePipelineShaders(ctx, accessor, sourcePackedState)},
|
shaderStages{MakePipelineShaders(gpu, accessor, sourcePackedState)},
|
||||||
descriptorInfo{MakePipelineDescriptorInfo(shaderStages, ctx.gpu.traits.quirks.needsIndividualTextureBindingWrites)},
|
descriptorInfo{MakePipelineDescriptorInfo(shaderStages, gpu.traits.quirks.needsIndividualTextureBindingWrites)},
|
||||||
compiledPipeline{MakeCompiledPipeline(ctx, sourcePackedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings)} {
|
compiledPipeline{MakeCompiledPipeline(gpu, sourcePackedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings)} {
|
||||||
storageBufferViews.resize(descriptorInfo.totalStorageBufferCount);
|
storageBufferViews.resize(descriptorInfo.totalStorageBufferCount);
|
||||||
|
accessor.MarkComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pipeline::SyncCachedStorageBufferViews(u32 executionNumber) {
|
void Pipeline::SyncCachedStorageBufferViews(ContextTag executionTag) {
|
||||||
if (lastExecutionNumber != executionNumber) {
|
if (lastExecutionTag != executionTag) {
|
||||||
for (auto &view : storageBufferViews)
|
for (auto &view : storageBufferViews)
|
||||||
view.PurgeCaches();
|
view.PurgeCaches();
|
||||||
|
|
||||||
lastExecutionNumber = executionNumber;
|
lastExecutionTag = executionTag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
#include <gpu/cache/graphics_pipeline_cache.h>
|
#include <gpu/cache/graphics_pipeline_cache.h>
|
||||||
#include <gpu/interconnect/common/samplers.h>
|
#include <gpu/interconnect/common/samplers.h>
|
||||||
#include <gpu/interconnect/common/textures.h>
|
#include <gpu/interconnect/common/textures.h>
|
||||||
|
#include <gpu/interconnect/common/pipeline_state_accessor.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "packed_pipeline_state.h"
|
#include "packed_pipeline_state.h"
|
||||||
#include "constant_buffers.h"
|
#include "constant_buffers.h"
|
||||||
#include "graphics_pipeline_state_accessor.h"
|
|
||||||
|
|
||||||
namespace skyline::gpu {
|
namespace skyline::gpu {
|
||||||
class TextureView;
|
class TextureView;
|
||||||
@ -95,13 +95,13 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
|
|
||||||
tsl::robin_map<Pipeline *, bool> bindingMatchCache; //!< Cache of which pipelines have bindings that match this pipeline
|
tsl::robin_map<Pipeline *, bool> bindingMatchCache; //!< Cache of which pipelines have bindings that match this pipeline
|
||||||
|
|
||||||
void SyncCachedStorageBufferViews(u32 executionNumber);
|
void SyncCachedStorageBufferViews(ContextTag executionTag);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cache::GraphicsPipelineCache::CompiledPipeline compiledPipeline;
|
cache::GraphicsPipelineCache::CompiledPipeline compiledPipeline;
|
||||||
size_t sampledImageCount{};
|
size_t sampledImageCount{};
|
||||||
|
|
||||||
Pipeline(InterconnectContext &ctx, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState);
|
Pipeline(GPU &gpu, PipelineStateAccessor &accessor, const PackedPipelineState &packedState);
|
||||||
|
|
||||||
Pipeline *LookupNext(const PackedPipelineState &packedState);
|
Pipeline *LookupNext(const PackedPipelineState &packedState);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user