mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
VideoCommon: De-globalize PixelShaderManager class.
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DBoundingBox.h"
|
||||
#include "VideoBackends/D3D/D3DRender.h"
|
||||
@ -260,6 +262,8 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
|
||||
|
||||
void VertexManager::UploadUniforms()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
|
||||
if (VertexShaderManager::dirty)
|
||||
{
|
||||
UpdateConstantBuffer(m_vertex_constant_buffer.Get(), &VertexShaderManager::constants,
|
||||
@ -272,11 +276,13 @@ void VertexManager::UploadUniforms()
|
||||
sizeof(GeometryShaderConstants));
|
||||
GeometryShaderManager::dirty = false;
|
||||
}
|
||||
if (PixelShaderManager::dirty)
|
||||
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
if (pixel_shader_manager.dirty)
|
||||
{
|
||||
UpdateConstantBuffer(m_pixel_constant_buffer.Get(), &PixelShaderManager::constants,
|
||||
UpdateConstantBuffer(m_pixel_constant_buffer.Get(), &pixel_shader_manager.constants,
|
||||
sizeof(PixelShaderConstants));
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
D3D::stateman->SetPixelConstants(
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/D3D12/D3D12Renderer.h"
|
||||
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
|
||||
#include "VideoBackends/D3D12/DX12Context.h"
|
||||
@ -169,15 +171,18 @@ void VertexManager::UpdateGeometryShaderConstants()
|
||||
|
||||
void VertexManager::UpdatePixelShaderConstants()
|
||||
{
|
||||
if (!PixelShaderManager::dirty || !ReserveConstantStorage())
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
if (!pixel_shader_manager.dirty || !ReserveConstantStorage())
|
||||
return;
|
||||
|
||||
Renderer::GetInstance()->SetConstantBuffer(0, m_uniform_stream_buffer.GetCurrentGPUPointer());
|
||||
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &PixelShaderManager::constants,
|
||||
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &pixel_shader_manager.constants,
|
||||
sizeof(PixelShaderConstants));
|
||||
m_uniform_stream_buffer.CommitMemory(sizeof(PixelShaderConstants));
|
||||
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(PixelShaderConstants));
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
bool VertexManager::ReserveConstantStorage()
|
||||
@ -230,9 +235,12 @@ void VertexManager::UploadAllConstants()
|
||||
Renderer::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer() +
|
||||
geometry_constants_offset);
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
// Copy the actual data in
|
||||
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + pixel_constants_offset,
|
||||
&PixelShaderManager::constants, sizeof(PixelShaderConstants));
|
||||
&pixel_shader_manager.constants, sizeof(PixelShaderConstants));
|
||||
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + vertex_constants_offset,
|
||||
&VertexShaderManager::constants, sizeof(VertexShaderConstants));
|
||||
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + geometry_constants_offset,
|
||||
@ -245,7 +253,7 @@ void VertexManager::UploadAllConstants()
|
||||
// Clear dirty flags
|
||||
VertexShaderManager::dirty = false;
|
||||
GeometryShaderManager::dirty = false;
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size)
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "Common/Assert.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/Metal/MTLObjectCache.h"
|
||||
#include "VideoBackends/Metal/MTLPerfQuery.h"
|
||||
#include "VideoBackends/Metal/MTLPipeline.h"
|
||||
@ -853,7 +855,9 @@ void Metal::StateTracker::PrepareRender()
|
||||
{
|
||||
m_flags.has_gx_ps_uniform = true;
|
||||
Map map = Allocate(UploadBuffer::Uniform, sizeof(PixelShaderConstants), AlignMask::Uniform);
|
||||
memcpy(map.cpu_buffer, &PixelShaderManager::constants, sizeof(PixelShaderConstants));
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
memcpy(map.cpu_buffer, &pixel_shader_manager.constants, sizeof(PixelShaderConstants));
|
||||
SetFragmentBufferNow(0, map.gpu_buffer, map.gpu_offset);
|
||||
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed,
|
||||
Align(sizeof(PixelShaderConstants), AlignMask::Uniform));
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "VideoBackends/Metal/MTLVertexManager.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/Metal/MTLStateTracker.h"
|
||||
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
@ -89,9 +91,11 @@ void Metal::VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32
|
||||
|
||||
void Metal::VertexManager::UploadUniforms()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
g_state_tracker->InvalidateUniforms(VertexShaderManager::dirty, GeometryShaderManager::dirty,
|
||||
PixelShaderManager::dirty);
|
||||
pixel_shader_manager.dirty);
|
||||
VertexShaderManager::dirty = false;
|
||||
GeometryShaderManager::dirty = false;
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Common/Version.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/OGL/OGLRender.h"
|
||||
#include "VideoBackends/OGL/OGLShader.h"
|
||||
@ -220,11 +221,13 @@ u32 ProgramShaderCache::GetUniformBufferAlignment()
|
||||
|
||||
void ProgramShaderCache::UploadConstants()
|
||||
{
|
||||
if (PixelShaderManager::dirty || VertexShaderManager::dirty || GeometryShaderManager::dirty)
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
if (pixel_shader_manager.dirty || VertexShaderManager::dirty || GeometryShaderManager::dirty)
|
||||
{
|
||||
auto buffer = s_buffer->Map(s_ubo_buffer_size, s_ubo_align);
|
||||
|
||||
memcpy(buffer.first, &PixelShaderManager::constants, sizeof(PixelShaderConstants));
|
||||
memcpy(buffer.first, &pixel_shader_manager.constants, sizeof(PixelShaderConstants));
|
||||
|
||||
memcpy(buffer.first + Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align),
|
||||
&VertexShaderManager::constants, sizeof(VertexShaderConstants));
|
||||
@ -244,7 +247,7 @@ void ProgramShaderCache::UploadConstants()
|
||||
Common::AlignUp(sizeof(VertexShaderConstants), s_ubo_align),
|
||||
sizeof(GeometryShaderConstants));
|
||||
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
VertexShaderManager::dirty = false;
|
||||
GeometryShaderManager::dirty = false;
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/Software/EfbInterface.h"
|
||||
#include "VideoBackends/Software/SWBoundingBox.h"
|
||||
#include "VideoBackends/Software/TextureSampler.h"
|
||||
@ -396,13 +399,16 @@ void Tev::Draw()
|
||||
|
||||
INCSTAT(g_stats.this_frame.tev_pixels_in);
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
// initial color values
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Reg[static_cast<TevOutput>(i)].r = PixelShaderManager::constants.colors[i][0];
|
||||
Reg[static_cast<TevOutput>(i)].g = PixelShaderManager::constants.colors[i][1];
|
||||
Reg[static_cast<TevOutput>(i)].b = PixelShaderManager::constants.colors[i][2];
|
||||
Reg[static_cast<TevOutput>(i)].a = PixelShaderManager::constants.colors[i][3];
|
||||
Reg[static_cast<TevOutput>(i)].r = pixel_shader_manager.constants.colors[i][0];
|
||||
Reg[static_cast<TevOutput>(i)].g = pixel_shader_manager.constants.colors[i][1];
|
||||
Reg[static_cast<TevOutput>(i)].b = pixel_shader_manager.constants.colors[i][2];
|
||||
Reg[static_cast<TevOutput>(i)].a = pixel_shader_manager.constants.colors[i][3];
|
||||
}
|
||||
|
||||
for (unsigned int stageNum = 0; stageNum < bpmem.genMode.numindstages; stageNum++)
|
||||
@ -694,11 +700,14 @@ void Tev::Draw()
|
||||
|
||||
void Tev::SetKonstColors()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
KonstantColors[i].r = PixelShaderManager::constants.kcolors[i][0];
|
||||
KonstantColors[i].g = PixelShaderManager::constants.kcolors[i][1];
|
||||
KonstantColors[i].b = PixelShaderManager::constants.kcolors[i][2];
|
||||
KonstantColors[i].a = PixelShaderManager::constants.kcolors[i][3];
|
||||
KonstantColors[i].r = pixel_shader_manager.constants.kcolors[i][0];
|
||||
KonstantColors[i].g = pixel_shader_manager.constants.kcolors[i][1];
|
||||
KonstantColors[i].b = pixel_shader_manager.constants.kcolors[i][2];
|
||||
KonstantColors[i].a = pixel_shader_manager.constants.kcolors[i][3];
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "VideoBackends/Vulkan/CommandBufferManager.h"
|
||||
#include "VideoBackends/Vulkan/StateTracker.h"
|
||||
#include "VideoBackends/Vulkan/VKRenderer.h"
|
||||
@ -232,17 +234,20 @@ void VertexManager::UpdateGeometryShaderConstants()
|
||||
|
||||
void VertexManager::UpdatePixelShaderConstants()
|
||||
{
|
||||
if (!PixelShaderManager::dirty || !ReserveConstantStorage())
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
if (!pixel_shader_manager.dirty || !ReserveConstantStorage())
|
||||
return;
|
||||
|
||||
StateTracker::GetInstance()->SetGXUniformBuffer(
|
||||
UBO_DESCRIPTOR_SET_BINDING_PS, m_uniform_stream_buffer->GetBuffer(),
|
||||
m_uniform_stream_buffer->GetCurrentOffset(), sizeof(PixelShaderConstants));
|
||||
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &PixelShaderManager::constants,
|
||||
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &pixel_shader_manager.constants,
|
||||
sizeof(PixelShaderConstants));
|
||||
m_uniform_stream_buffer->CommitMemory(sizeof(PixelShaderConstants));
|
||||
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(PixelShaderConstants));
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
bool VertexManager::ReserveConstantStorage()
|
||||
@ -282,6 +287,9 @@ void VertexManager::UploadAllConstants()
|
||||
return;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
// Update bindings
|
||||
StateTracker::GetInstance()->SetGXUniformBuffer(
|
||||
UBO_DESCRIPTOR_SET_BINDING_PS, m_uniform_stream_buffer->GetBuffer(),
|
||||
@ -298,7 +306,7 @@ void VertexManager::UploadAllConstants()
|
||||
|
||||
// Copy the actual data in
|
||||
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer() + pixel_constants_offset,
|
||||
&PixelShaderManager::constants, sizeof(PixelShaderConstants));
|
||||
&pixel_shader_manager.constants, sizeof(PixelShaderConstants));
|
||||
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer() + vertex_constants_offset,
|
||||
&VertexShaderManager::constants, sizeof(VertexShaderConstants));
|
||||
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer() + geometry_constants_offset,
|
||||
@ -311,7 +319,7 @@ void VertexManager::UploadAllConstants()
|
||||
// Clear dirty flags
|
||||
VertexShaderManager::dirty = false;
|
||||
GeometryShaderManager::dirty = false;
|
||||
PixelShaderManager::dirty = false;
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size)
|
||||
|
Reference in New Issue
Block a user