mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VideoBackends / VideoCommon: add new uniform buffer object for custom shader materials (slot 3, geometry shader buffer moves to slot 4 if available)
This commit is contained in:
@ -69,12 +69,18 @@ void StateManager::Apply()
|
||||
if (dirtyConstants)
|
||||
{
|
||||
if (m_current.pixelConstants[0] != m_pending.pixelConstants[0] ||
|
||||
m_current.pixelConstants[1] != m_pending.pixelConstants[1])
|
||||
m_current.pixelConstants[1] != m_pending.pixelConstants[1] ||
|
||||
m_current.pixelConstants[2] != m_pending.pixelConstants[2])
|
||||
{
|
||||
D3D::context->PSSetConstantBuffers(0, m_pending.pixelConstants[1] ? 2 : 1,
|
||||
m_pending.pixelConstants.data());
|
||||
u32 count = 1;
|
||||
if (m_pending.pixelConstants[1])
|
||||
count++;
|
||||
if (m_pending.pixelConstants[2])
|
||||
count++;
|
||||
D3D::context->PSSetConstantBuffers(0, count, m_pending.pixelConstants.data());
|
||||
m_current.pixelConstants[0] = m_pending.pixelConstants[0];
|
||||
m_current.pixelConstants[1] = m_pending.pixelConstants[1];
|
||||
m_current.pixelConstants[2] = m_pending.pixelConstants[2];
|
||||
}
|
||||
|
||||
if (m_current.vertexConstants != m_pending.vertexConstants)
|
||||
|
@ -91,13 +91,16 @@ public:
|
||||
m_pending.samplers[index] = sampler;
|
||||
}
|
||||
|
||||
void SetPixelConstants(ID3D11Buffer* buffer0, ID3D11Buffer* buffer1 = nullptr)
|
||||
void SetPixelConstants(ID3D11Buffer* buffer0, ID3D11Buffer* buffer1 = nullptr,
|
||||
ID3D11Buffer* buffer2 = nullptr)
|
||||
{
|
||||
if (m_current.pixelConstants[0] != buffer0 || m_current.pixelConstants[1] != buffer1)
|
||||
if (m_current.pixelConstants[0] != buffer0 || m_current.pixelConstants[1] != buffer1 ||
|
||||
m_current.pixelConstants[2] != buffer2)
|
||||
m_dirtyFlags.set(DirtyFlag_PixelConstants);
|
||||
|
||||
m_pending.pixelConstants[0] = buffer0;
|
||||
m_pending.pixelConstants[1] = buffer1;
|
||||
m_pending.pixelConstants[2] = buffer2;
|
||||
}
|
||||
|
||||
void SetVertexConstants(ID3D11Buffer* buffer)
|
||||
@ -252,7 +255,7 @@ private:
|
||||
{
|
||||
std::array<ID3D11ShaderResourceView*, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> textures;
|
||||
std::array<ID3D11SamplerState*, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> samplers;
|
||||
std::array<ID3D11Buffer*, 2> pixelConstants;
|
||||
std::array<ID3D11Buffer*, 3> pixelConstants;
|
||||
ID3D11Buffer* vertexConstants;
|
||||
ID3D11Buffer* geometryConstants;
|
||||
ID3D11Buffer* vertexBuffer;
|
||||
|
@ -288,9 +288,25 @@ void VertexManager::UploadUniforms()
|
||||
pixel_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
if (pixel_shader_manager.custom_constants_dirty)
|
||||
{
|
||||
if (m_last_custom_pixel_buffer_size < pixel_shader_manager.custom_constants.size())
|
||||
{
|
||||
m_custom_pixel_constant_buffer =
|
||||
AllocateConstantBuffer(static_cast<u32>(pixel_shader_manager.custom_constants.size()));
|
||||
}
|
||||
UpdateConstantBuffer(m_custom_pixel_constant_buffer.Get(),
|
||||
pixel_shader_manager.custom_constants.data(),
|
||||
static_cast<u32>(pixel_shader_manager.custom_constants.size()));
|
||||
m_last_custom_pixel_buffer_size = pixel_shader_manager.custom_constants.size();
|
||||
pixel_shader_manager.custom_constants_dirty = false;
|
||||
}
|
||||
|
||||
D3D::stateman->SetPixelConstants(
|
||||
m_pixel_constant_buffer.Get(),
|
||||
g_ActiveConfig.bEnablePixelLighting ? m_vertex_constant_buffer.Get() : nullptr);
|
||||
g_ActiveConfig.bEnablePixelLighting ? m_vertex_constant_buffer.Get() : nullptr,
|
||||
pixel_shader_manager.custom_constants.empty() ? nullptr :
|
||||
m_custom_pixel_constant_buffer.Get());
|
||||
D3D::stateman->SetVertexConstants(m_vertex_constant_buffer.Get());
|
||||
D3D::stateman->SetGeometryConstants(m_geometry_constant_buffer.Get());
|
||||
}
|
||||
|
@ -68,6 +68,9 @@ private:
|
||||
ComPtr<ID3D11Buffer> m_geometry_constant_buffer = nullptr;
|
||||
ComPtr<ID3D11Buffer> m_pixel_constant_buffer = nullptr;
|
||||
|
||||
ComPtr<ID3D11Buffer> m_custom_pixel_constant_buffer = nullptr;
|
||||
std::size_t m_last_custom_pixel_buffer_size = 0;
|
||||
|
||||
ComPtr<ID3D11Buffer> m_texel_buffer = nullptr;
|
||||
std::array<ComPtr<ID3D11ShaderResourceView>, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views;
|
||||
u32 m_texel_buffer_offset = 0;
|
||||
|
Reference in New Issue
Block a user