Просмотр исходного кода

GPU: Added a function to determine whether a shader stage is enabled or not.

Subv 8 лет назад
Родитель
Сommit
ae58e46036

+ 21 - 0
src/video_core/engines/maxwell_3d.cpp

@@ -301,5 +301,26 @@ u32 Maxwell3D::GetRegisterValue(u32 method) const {
     return regs.reg_array[method];
     return regs.reg_array[method];
 }
 }
 
 
+bool Maxwell3D::IsShaderStageEnabled(Regs::ShaderStage stage) const {
+    // The Vertex stage is always enabled.
+    if (stage == Regs::ShaderStage::Vertex)
+        return true;
+
+    switch (stage) {
+    case Regs::ShaderStage::TesselationControl:
+        return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::TesselationControl)]
+                   .enable != 0;
+    case Regs::ShaderStage::TesselationEval:
+        return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::TesselationEval)]
+                   .enable != 0;
+    case Regs::ShaderStage::Geometry:
+        return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::Geometry)].enable != 0;
+    case Regs::ShaderStage::Fragment:
+        return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::Fragment)].enable != 0;
+    }
+
+    UNREACHABLE();
+}
+
 } // namespace Engines
 } // namespace Engines
 } // namespace Tegra
 } // namespace Tegra

+ 3 - 0
src/video_core/engines/maxwell_3d.h

@@ -518,6 +518,9 @@ public:
     /// Returns a list of enabled textures for the specified shader stage.
     /// Returns a list of enabled textures for the specified shader stage.
     std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const;
     std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const;
 
 
+    /// Returns whether the specified shader stage is enabled or not.
+    bool IsShaderStageEnabled(Regs::ShaderStage stage) const;
+
 private:
 private:
     std::unordered_map<u32, std::vector<u32>> uploaded_macros;
     std::unordered_map<u32, std::vector<u32>> uploaded_macros;
 
 

+ 3 - 3
src/video_core/renderer_opengl/gl_rasterizer.cpp

@@ -191,8 +191,9 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
         auto& shader_config = gpu.regs.shader_config[index];
         auto& shader_config = gpu.regs.shader_config[index];
         const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
         const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
 
 
-        // VertexB program is always enabled, despite bit setting
-        const bool is_enabled{shader_config.enable || program == Maxwell::ShaderProgram::VertexB};
+        const auto& stage = index - 1; // Stage indices are 0 - 5
+
+        const bool is_enabled = gpu.IsShaderStageEnabled(static_cast<Maxwell::ShaderStage>(stage));
 
 
         // Skip stages that are not enabled
         // Skip stages that are not enabled
         if (!is_enabled) {
         if (!is_enabled) {
@@ -200,7 +201,6 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
         }
         }
 
 
         // Upload uniform data as one UBO per stage
         // Upload uniform data as one UBO per stage
-        const auto& stage = index - 1; // Stage indices are 0 - 5
         const GLintptr ubo_offset = buffer_offset + static_cast<GLintptr>(ptr_pos);
         const GLintptr ubo_offset = buffer_offset + static_cast<GLintptr>(ptr_pos);
         copy_buffer(uniform_buffers[stage].handle, ubo_offset,
         copy_buffer(uniform_buffers[stage].handle, ubo_offset,
                     sizeof(GLShader::MaxwellUniformData));
                     sizeof(GLShader::MaxwellUniformData));