Retain Shader Binding State Across Stages

An instance of `Shader::Backend::Bindings` must be retained across all stages for correct emission of bindings, which is now done inside `GraphicsContext::GetShaderStages`.
This commit is contained in:
PixelyIon 2021-12-11 12:52:41 +05:30
parent 550d12b7fa
commit afa34e320a
3 changed files with 7 additions and 6 deletions

View File

@ -546,6 +546,7 @@ namespace skyline::gpu::interconnect {
span<vk::PipelineShaderStageCreateInfo> GetShaderStages() {
if (!activeShaderStagesInfoCount) {
runtimeInfo.previous_stage_stores.mask.set(); // First stage should always have all bits set
ShaderCompiler::Backend::Bindings bindings;
size_t count{};
for (auto &shader : shaders) {
@ -586,7 +587,7 @@ namespace skyline::gpu::interconnect {
return std::nullopt;
})};
shader.vkModule = gpu.shader.CompileGraphicsShader(shader.data, shader.stage, shader.offset, runtimeInfo);
shader.vkModule = gpu.shader.CompileGraphicsShader(shader.data, shader.stage, shader.offset, runtimeInfo, bindings);
}
shaderStagesInfo[count++] = vk::PipelineShaderStageCreateInfo{

View File

@ -125,13 +125,12 @@ namespace skyline::gpu {
}
};
vk::raii::ShaderModule ShaderManager::CompileGraphicsShader(const std::vector<u8> &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo& runtimeInfo) {
vk::raii::ShaderModule ShaderManager::CompileGraphicsShader(const std::vector<u8> &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo &runtimeInfo, Shader::Backend::Bindings &bindings) {
GraphicsEnvironment environment{binary, baseOffset, stage};
Shader::Maxwell::Flow::CFG cfg(environment, flowBlockPool, Shader::Maxwell::Location{static_cast<u32>(baseOffset + sizeof(Shader::ProgramHeader))});
auto program{Shader::Maxwell::TranslateProgram(instPool, blockPool, environment, cfg, hostTranslateInfo)};
Shader::Backend::Bindings bindings{};
auto spirv{Shader::Backend::SPIRV::EmitSPIRV(profile, runtimeInfo, program, bindings)};
runtimeInfo.previous_stage_stores = program.info.stores;

View File

@ -8,9 +8,10 @@
#include <shader_compiler/frontend/maxwell/control_flow.h>
#include <shader_compiler/frontend/ir/value.h>
#include <shader_compiler/frontend/ir/basic_block.h>
#include <shader_compiler/runtime_info.h>
#include <shader_compiler/host_translate_info.h>
#include <shader_compiler/profile.h>
#include <shader_compiler/runtime_info.h>
#include <shader_compiler/backend/bindings.h>
#include <common.h>
namespace skyline::gpu {
@ -27,11 +28,11 @@ namespace skyline::gpu {
Shader::Profile profile;
public:
ShaderManager(const DeviceState& state, GPU &gpu);
ShaderManager(const DeviceState &state, GPU &gpu);
/**
* @note `runtimeInfo::previous_stage_stores` will automatically be updated for the next stage
*/
vk::raii::ShaderModule CompileGraphicsShader(const std::vector<u8> &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo& runtimeInfo);
vk::raii::ShaderModule CompileGraphicsShader(const std::vector<u8> &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo &runtimeInfo, Shader::Backend::Bindings &bindings);
};
}