diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2023-09-19 19:27:12 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2023-10-05 21:20:16 -0500 |
| commit | 92accc3ef7bd599e112a67ee0095b22dd48c3055 (patch) | |
| tree | 81041dcd831e850fe97a8359fb9cc3bb13bf85b8 /Source | |
| parent | c86a0a04dd355ba9c7c475ae89c50cbff2e88d31 (diff) | |
VideoCommon: add custom pixel shader constants as a buffer of data to be passed to all backends
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderManager.h | 6 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexManagerBase.cpp | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderManager.h b/Source/Core/VideoCommon/PixelShaderManager.h index f0c8b5774f..5d3fe7257e 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.h +++ b/Source/Core/VideoCommon/PixelShaderManager.h @@ -3,6 +3,8 @@ #pragma once +#include <span> + #include "Common/CommonTypes.h" #include "VideoCommon/ConstantManager.h" @@ -52,6 +54,10 @@ public: PixelShaderConstants constants{}; bool dirty = false; + // Constants for custom shaders + std::span<u8> custom_constants; + bool custom_constants_dirty = false; + private: bool m_fog_range_adjusted_changed = false; bool m_viewport_changed = false; diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 2aac0f6f90..a7da900268 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -595,6 +595,7 @@ void VertexManagerBase::Flush() CustomPixelShaderContents custom_pixel_shader_contents; std::optional<CustomPixelShader> custom_pixel_shader; std::vector<std::string> custom_pixel_texture_names; + std::span<u8> custom_pixel_shader_uniforms; for (int i = 0; i < texture_names.size(); i++) { const std::string& texture_name = texture_names[i]; @@ -644,6 +645,12 @@ void VertexManagerBase::Flush() // Now we can upload uniforms, as nothing else will override them. geometry_shader_manager.SetConstants(m_current_primitive_type); pixel_shader_manager.SetConstants(); + if (!custom_pixel_shader_uniforms.empty() && + pixel_shader_manager.custom_constants.data() != custom_pixel_shader_uniforms.data()) + { + pixel_shader_manager.custom_constants_dirty = true; + } + pixel_shader_manager.custom_constants = custom_pixel_shader_uniforms; UploadUniforms(); // Update the pipeline, or compile one if needed. @@ -1052,7 +1059,8 @@ void VertexManagerBase::OnEndFrame() return; // In order to reduce CPU readback latency, we want to kick a command buffer roughly halfway - // between the draw counters that invoked the readback, or every 250 draws, whichever is smaller. + // between the draw counters that invoked the readback, or every 250 draws, whichever is + // smaller. if (g_ActiveConfig.iCommandBufferExecuteInterval > 0) { u32 last_draw_counter = 0; |
