summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-04-14 11:42:07 -0500
committerGravatar Subv2018-04-14 22:54:23 -0500
commitae58e46036944ebadfed611b657911720383d60f (patch)
tree951caf616779423ce11f1b260701492ceb07f187 /src
parentMerge pull request #332 from bunnei/fix-total-mem-usage (diff)
downloadyuzu-ae58e46036944ebadfed611b657911720383d60f.tar.gz
yuzu-ae58e46036944ebadfed611b657911720383d60f.tar.xz
yuzu-ae58e46036944ebadfed611b657911720383d60f.zip
GPU: Added a function to determine whether a shader stage is enabled or not.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp21
-rw-r--r--src/video_core/engines/maxwell_3d.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
3 files changed, 27 insertions, 3 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 2d7c3152f..98ed11ec5 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -301,5 +301,26 @@ u32 Maxwell3D::GetRegisterValue(u32 method) const {
301 return regs.reg_array[method]; 301 return regs.reg_array[method];
302} 302}
303 303
304bool Maxwell3D::IsShaderStageEnabled(Regs::ShaderStage stage) const {
305 // The Vertex stage is always enabled.
306 if (stage == Regs::ShaderStage::Vertex)
307 return true;
308
309 switch (stage) {
310 case Regs::ShaderStage::TesselationControl:
311 return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::TesselationControl)]
312 .enable != 0;
313 case Regs::ShaderStage::TesselationEval:
314 return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::TesselationEval)]
315 .enable != 0;
316 case Regs::ShaderStage::Geometry:
317 return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::Geometry)].enable != 0;
318 case Regs::ShaderStage::Fragment:
319 return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::Fragment)].enable != 0;
320 }
321
322 UNREACHABLE();
323}
324
304} // namespace Engines 325} // namespace Engines
305} // namespace Tegra 326} // namespace Tegra
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 9c6236c39..1fae41cb2 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -518,6 +518,9 @@ public:
518 /// Returns a list of enabled textures for the specified shader stage. 518 /// Returns a list of enabled textures for the specified shader stage.
519 std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const; 519 std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const;
520 520
521 /// Returns whether the specified shader stage is enabled or not.
522 bool IsShaderStageEnabled(Regs::ShaderStage stage) const;
523
521private: 524private:
522 std::unordered_map<u32, std::vector<u32>> uploaded_macros; 525 std::unordered_map<u32, std::vector<u32>> uploaded_macros;
523 526
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f75d4c658..adc684f9e 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -191,8 +191,9 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
191 auto& shader_config = gpu.regs.shader_config[index]; 191 auto& shader_config = gpu.regs.shader_config[index];
192 const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)}; 192 const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
193 193
194 // VertexB program is always enabled, despite bit setting 194 const auto& stage = index - 1; // Stage indices are 0 - 5
195 const bool is_enabled{shader_config.enable || program == Maxwell::ShaderProgram::VertexB}; 195
196 const bool is_enabled = gpu.IsShaderStageEnabled(static_cast<Maxwell::ShaderStage>(stage));
196 197
197 // Skip stages that are not enabled 198 // Skip stages that are not enabled
198 if (!is_enabled) { 199 if (!is_enabled) {
@@ -200,7 +201,6 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size
200 } 201 }
201 202
202 // Upload uniform data as one UBO per stage 203 // Upload uniform data as one UBO per stage
203 const auto& stage = index - 1; // Stage indices are 0 - 5
204 const GLintptr ubo_offset = buffer_offset + static_cast<GLintptr>(ptr_pos); 204 const GLintptr ubo_offset = buffer_offset + static_cast<GLintptr>(ptr_pos);
205 copy_buffer(uniform_buffers[stage].handle, ubo_offset, 205 copy_buffer(uniform_buffers[stage].handle, ubo_offset,
206 sizeof(GLShader::MaxwellUniformData)); 206 sizeof(GLShader::MaxwellUniformData));