From afa34e320a1726ab417aafebd4702e12bae6224e Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Sat, 11 Dec 2021 12:52:41 +0530 Subject: [PATCH] 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`. --- .../main/cpp/skyline/gpu/interconnect/graphics_context.h | 3 ++- app/src/main/cpp/skyline/gpu/shader_manager.cpp | 3 +-- app/src/main/cpp/skyline/gpu/shader_manager.h | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h index a3c48c5f..1a364f26 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -546,6 +546,7 @@ namespace skyline::gpu::interconnect { span 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{ diff --git a/app/src/main/cpp/skyline/gpu/shader_manager.cpp b/app/src/main/cpp/skyline/gpu/shader_manager.cpp index 61dfe6ec..621556d1 100644 --- a/app/src/main/cpp/skyline/gpu/shader_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/shader_manager.cpp @@ -125,13 +125,12 @@ namespace skyline::gpu { } }; - vk::raii::ShaderModule ShaderManager::CompileGraphicsShader(const std::vector &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo& runtimeInfo) { + vk::raii::ShaderModule ShaderManager::CompileGraphicsShader(const std::vector &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(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; diff --git a/app/src/main/cpp/skyline/gpu/shader_manager.h b/app/src/main/cpp/skyline/gpu/shader_manager.h index f0005783..1cc5af23 100644 --- a/app/src/main/cpp/skyline/gpu/shader_manager.h +++ b/app/src/main/cpp/skyline/gpu/shader_manager.h @@ -8,9 +8,10 @@ #include #include #include -#include #include #include +#include +#include #include 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 &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo& runtimeInfo); + vk::raii::ShaderModule CompileGraphicsShader(const std::vector &binary, Shader::Stage stage, u32 baseOffset, Shader::RuntimeInfo &runtimeInfo, Shader::Backend::Bindings &bindings); }; }