2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2020-09-15 12:50:34 +00:00
|
|
|
#include "VideoBackends/D3D/D3DVertexManager.h"
|
2017-02-01 04:29:29 +00:00
|
|
|
|
|
|
|
#include <d3d11.h>
|
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
#include "Common/Align.h"
|
2019-02-15 01:59:50 +00:00
|
|
|
#include "Common/Assert.h"
|
2016-01-02 20:01:12 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2022-12-27 16:42:02 +00:00
|
|
|
#include "Core/System.h"
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/D3D/D3DBase.h"
|
2020-09-15 12:50:34 +00:00
|
|
|
#include "VideoBackends/D3D/D3DBoundingBox.h"
|
|
|
|
#include "VideoBackends/D3D/D3DRender.h"
|
2014-10-29 00:19:09 +00:00
|
|
|
#include "VideoBackends/D3D/D3DState.h"
|
2020-09-15 13:07:22 +00:00
|
|
|
#include "VideoBackends/D3DCommon/D3DCommon.h"
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2014-12-05 02:01:20 +00:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
2018-11-27 07:16:53 +00:00
|
|
|
#include "VideoCommon/GeometryShaderManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/IndexGenerator.h"
|
2017-02-01 04:29:29 +00:00
|
|
|
#include "VideoCommon/NativeVertexFormat.h"
|
2018-11-27 07:16:53 +00:00
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/Statistics.h"
|
2014-07-25 23:10:44 +00:00
|
|
|
#include "VideoCommon/VertexLoaderManager.h"
|
2018-11-27 07:16:53 +00:00
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2010-10-03 00:41:06 +00:00
|
|
|
namespace DX11
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2019-03-09 13:31:37 +00:00
|
|
|
static ComPtr<ID3D11Buffer> AllocateConstantBuffer(u32 size)
|
2018-11-27 07:16:53 +00:00
|
|
|
{
|
|
|
|
const u32 cbsize = Common::AlignUp(size, 16u); // must be a multiple of 16
|
|
|
|
const CD3D11_BUFFER_DESC cbdesc(cbsize, D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC,
|
|
|
|
D3D11_CPU_ACCESS_WRITE);
|
2019-03-09 13:31:37 +00:00
|
|
|
ComPtr<ID3D11Buffer> cbuf;
|
2018-11-27 07:16:53 +00:00
|
|
|
const HRESULT hr = D3D::device->CreateBuffer(&cbdesc, nullptr, &cbuf);
|
2021-12-12 20:50:13 +00:00
|
|
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create shader constant buffer (size={}): {}", cbsize,
|
|
|
|
DX11HRWrap(hr));
|
2019-03-09 13:31:36 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return nullptr;
|
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
D3DCommon::SetDebugObjectName(cbuf.Get(), "constant buffer");
|
2018-11-27 07:16:53 +00:00
|
|
|
return cbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UpdateConstantBuffer(ID3D11Buffer* const buffer, const void* data, u32 data_size)
|
|
|
|
{
|
|
|
|
D3D11_MAPPED_SUBRESOURCE map;
|
|
|
|
D3D::context->Map(buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
|
|
|
memcpy(map.pData, data, data_size);
|
|
|
|
D3D::context->Unmap(buffer, 0);
|
|
|
|
|
2019-07-11 03:34:50 +00:00
|
|
|
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
|
2018-11-27 07:16:53 +00:00
|
|
|
}
|
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
static ComPtr<ID3D11ShaderResourceView>
|
2019-02-15 01:59:50 +00:00
|
|
|
CreateTexelBufferView(ID3D11Buffer* buffer, TexelBufferFormat format, DXGI_FORMAT srv_format)
|
2010-10-03 00:41:06 +00:00
|
|
|
{
|
2019-03-09 13:31:37 +00:00
|
|
|
ComPtr<ID3D11ShaderResourceView> srv;
|
2019-02-15 01:59:50 +00:00
|
|
|
CD3D11_SHADER_RESOURCE_VIEW_DESC srv_desc(buffer, srv_format, 0,
|
|
|
|
VertexManager::TEXEL_STREAM_BUFFER_SIZE /
|
|
|
|
VertexManager::GetTexelBufferElementSize(format));
|
2021-11-10 23:55:33 +00:00
|
|
|
HRESULT hr = D3D::device->CreateShaderResourceView(buffer, &srv_desc, &srv);
|
2021-12-12 20:50:13 +00:00
|
|
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create SRV for texel buffer: {}", DX11HRWrap(hr));
|
2019-02-15 01:59:50 +00:00
|
|
|
return srv;
|
|
|
|
}
|
|
|
|
|
|
|
|
VertexManager::VertexManager() = default;
|
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
VertexManager::~VertexManager() = default;
|
2019-02-15 01:59:50 +00:00
|
|
|
|
|
|
|
bool VertexManager::Initialize()
|
|
|
|
{
|
|
|
|
if (!VertexManagerBase::Initialize())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
CD3D11_BUFFER_DESC bufdesc((VERTEX_STREAM_BUFFER_SIZE + INDEX_STREAM_BUFFER_SIZE) / BUFFER_COUNT,
|
|
|
|
D3D11_BIND_INDEX_BUFFER | D3D11_BIND_VERTEX_BUFFER,
|
|
|
|
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
for (int i = 0; i < BUFFER_COUNT; i++)
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2021-11-10 23:55:33 +00:00
|
|
|
HRESULT hr = D3D::device->CreateBuffer(&bufdesc, nullptr, &m_buffers[i]);
|
2021-12-12 20:50:13 +00:00
|
|
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create buffer: {}", DX11HRWrap(hr));
|
2019-03-09 13:31:36 +00:00
|
|
|
if (m_buffers[i])
|
2019-03-09 13:31:37 +00:00
|
|
|
D3DCommon::SetDebugObjectName(m_buffers[i].Get(), "Buffer of VertexManager");
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
m_vertex_constant_buffer = AllocateConstantBuffer(sizeof(VertexShaderConstants));
|
|
|
|
m_geometry_constant_buffer = AllocateConstantBuffer(sizeof(GeometryShaderConstants));
|
|
|
|
m_pixel_constant_buffer = AllocateConstantBuffer(sizeof(PixelShaderConstants));
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!m_vertex_constant_buffer || !m_geometry_constant_buffer || !m_pixel_constant_buffer)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
CD3D11_BUFFER_DESC texel_buf_desc(TEXEL_STREAM_BUFFER_SIZE, D3D11_BIND_SHADER_RESOURCE,
|
|
|
|
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
2021-11-10 23:55:33 +00:00
|
|
|
HRESULT hr = D3D::device->CreateBuffer(&texel_buf_desc, nullptr, &m_texel_buffer);
|
2021-12-12 20:50:13 +00:00
|
|
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating texel buffer failed: {}", DX11HRWrap(hr));
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!m_texel_buffer)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
static constexpr std::array<std::pair<TexelBufferFormat, DXGI_FORMAT>, NUM_TEXEL_BUFFER_FORMATS>
|
|
|
|
format_mapping = {{
|
|
|
|
{TEXEL_BUFFER_FORMAT_R8_UINT, DXGI_FORMAT_R8_UINT},
|
|
|
|
{TEXEL_BUFFER_FORMAT_R16_UINT, DXGI_FORMAT_R16_UINT},
|
2019-02-28 10:35:17 +00:00
|
|
|
{TEXEL_BUFFER_FORMAT_RGBA8_UINT, DXGI_FORMAT_R8G8B8A8_UINT},
|
2019-02-15 01:59:50 +00:00
|
|
|
{TEXEL_BUFFER_FORMAT_R32G32_UINT, DXGI_FORMAT_R32G32_UINT},
|
|
|
|
}};
|
|
|
|
for (const auto& it : format_mapping)
|
|
|
|
{
|
2019-03-09 13:31:37 +00:00
|
|
|
m_texel_buffer_views[it.first] =
|
|
|
|
CreateTexelBufferView(m_texel_buffer.Get(), it.first, it.second);
|
2019-02-15 01:59:50 +00:00
|
|
|
if (!m_texel_buffer_views[it.first])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
void VertexManager::UploadUtilityUniforms(const void* uniforms, u32 uniforms_size)
|
2011-06-11 19:37:21 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
// Just use the one buffer for all three.
|
|
|
|
InvalidateConstants();
|
2019-03-09 13:31:37 +00:00
|
|
|
UpdateConstantBuffer(m_vertex_constant_buffer.Get(), uniforms, uniforms_size);
|
|
|
|
D3D::stateman->SetVertexConstants(m_vertex_constant_buffer.Get());
|
|
|
|
D3D::stateman->SetGeometryConstants(m_vertex_constant_buffer.Get());
|
|
|
|
D3D::stateman->SetPixelConstants(m_vertex_constant_buffer.Get());
|
2019-02-15 01:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VertexManager::MapTexelBuffer(u32 required_size, D3D11_MAPPED_SUBRESOURCE& sr)
|
|
|
|
{
|
|
|
|
if ((m_texel_buffer_offset + required_size) > TEXEL_STREAM_BUFFER_SIZE)
|
|
|
|
{
|
|
|
|
// Restart buffer.
|
2019-03-09 13:31:37 +00:00
|
|
|
HRESULT hr = D3D::context->Map(m_texel_buffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &sr);
|
2021-12-12 20:50:13 +00:00
|
|
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map texel buffer: {}", DX11HRWrap(hr));
|
2019-02-15 01:59:50 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_texel_buffer_offset = 0;
|
|
|
|
}
|
|
|
|
else
|
2012-10-20 13:22:15 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
// Don't overwrite the earlier-used space.
|
2019-03-09 13:31:37 +00:00
|
|
|
HRESULT hr = D3D::context->Map(m_texel_buffer.Get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &sr);
|
2021-12-12 20:50:13 +00:00
|
|
|
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map texel buffer: {}", DX11HRWrap(hr));
|
2019-02-15 01:59:50 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return false;
|
2012-10-20 13:22:15 +00:00
|
|
|
}
|
2019-02-15 01:59:50 +00:00
|
|
|
|
|
|
|
return true;
|
2011-06-11 19:37:21 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format,
|
|
|
|
u32* out_offset)
|
2011-06-11 19:37:21 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
if (data_size > TEXEL_STREAM_BUFFER_SIZE)
|
|
|
|
return false;
|
2014-10-25 17:04:33 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
const u32 elem_size = GetTexelBufferElementSize(format);
|
|
|
|
m_texel_buffer_offset = Common::AlignUp(m_texel_buffer_offset, elem_size);
|
2014-01-23 14:27:18 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
D3D11_MAPPED_SUBRESOURCE sr;
|
|
|
|
if (!MapTexelBuffer(data_size, sr))
|
|
|
|
return false;
|
2014-01-23 14:27:18 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
*out_offset = m_texel_buffer_offset / elem_size;
|
|
|
|
std::memcpy(static_cast<u8*>(sr.pData) + m_texel_buffer_offset, data, data_size);
|
2019-07-11 03:34:50 +00:00
|
|
|
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
|
2019-02-15 01:59:50 +00:00
|
|
|
m_texel_buffer_offset += data_size;
|
2011-06-11 19:37:21 +00:00
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
D3D::context->Unmap(m_texel_buffer.Get(), 0);
|
|
|
|
D3D::stateman->SetTexture(0, m_texel_buffer_views[static_cast<size_t>(format)].Get());
|
2019-02-15 01:59:50 +00:00
|
|
|
return true;
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format,
|
|
|
|
u32* out_offset, const void* palette_data, u32 palette_size,
|
|
|
|
TexelBufferFormat palette_format, u32* out_palette_offset)
|
2018-11-27 07:16:53 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
const u32 elem_size = GetTexelBufferElementSize(format);
|
|
|
|
const u32 palette_elem_size = GetTexelBufferElementSize(palette_format);
|
|
|
|
const u32 reserve_size = data_size + palette_size + palette_elem_size;
|
|
|
|
if (reserve_size > TEXEL_STREAM_BUFFER_SIZE)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_texel_buffer_offset = Common::AlignUp(m_texel_buffer_offset, elem_size);
|
|
|
|
|
|
|
|
D3D11_MAPPED_SUBRESOURCE sr;
|
|
|
|
if (!MapTexelBuffer(reserve_size, sr))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const u32 palette_byte_offset = Common::AlignUp(data_size, palette_elem_size);
|
|
|
|
std::memcpy(static_cast<u8*>(sr.pData) + m_texel_buffer_offset, data, data_size);
|
|
|
|
std::memcpy(static_cast<u8*>(sr.pData) + m_texel_buffer_offset + palette_byte_offset,
|
|
|
|
palette_data, palette_size);
|
2019-07-11 03:34:50 +00:00
|
|
|
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, palette_byte_offset + palette_size);
|
2019-02-15 01:59:50 +00:00
|
|
|
*out_offset = m_texel_buffer_offset / elem_size;
|
|
|
|
*out_palette_offset = (m_texel_buffer_offset + palette_byte_offset) / palette_elem_size;
|
|
|
|
m_texel_buffer_offset += palette_byte_offset + palette_size;
|
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
D3D::context->Unmap(m_texel_buffer.Get(), 0);
|
|
|
|
D3D::stateman->SetTexture(0, m_texel_buffer_views[static_cast<size_t>(format)].Get());
|
|
|
|
D3D::stateman->SetTexture(1, m_texel_buffer_views[static_cast<size_t>(palette_format)].Get());
|
2019-02-15 01:59:50 +00:00
|
|
|
return true;
|
2018-11-27 07:16:53 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
void VertexManager::ResetBuffer(u32 vertex_stride)
|
2018-11-27 07:16:53 +00:00
|
|
|
{
|
2019-02-15 01:59:50 +00:00
|
|
|
m_base_buffer_pointer = m_cpu_vertex_buffer.data();
|
2018-11-27 07:16:53 +00:00
|
|
|
m_cur_buffer_pointer = m_base_buffer_pointer;
|
2019-02-15 01:59:50 +00:00
|
|
|
m_end_buffer_pointer = m_base_buffer_pointer + m_cpu_vertex_buffer.size();
|
2019-12-05 15:01:33 +00:00
|
|
|
m_index_generator.Start(m_cpu_index_buffer.data());
|
2018-11-27 07:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_indices,
|
|
|
|
u32* out_base_vertex, u32* out_base_index)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
|
|
|
D3D11_MAPPED_SUBRESOURCE map;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
u32 vertexBufferSize = Common::AlignUp(num_vertices * vertex_stride, sizeof(u16));
|
|
|
|
u32 indexBufferSize = num_indices * sizeof(u16);
|
2014-10-25 17:04:33 +00:00
|
|
|
u32 totalBufferSize = vertexBufferSize + indexBufferSize;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
u32 cursor = m_buffer_cursor;
|
|
|
|
u32 padding = vertex_stride > 0 ? (m_buffer_cursor % vertex_stride) : 0;
|
2014-10-25 17:04:33 +00:00
|
|
|
if (padding)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2018-11-27 07:16:53 +00:00
|
|
|
cursor += vertex_stride - padding;
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-10-25 17:04:33 +00:00
|
|
|
D3D11_MAP MapType = D3D11_MAP_WRITE_NO_OVERWRITE;
|
2019-02-15 01:59:50 +00:00
|
|
|
if (cursor + totalBufferSize >= BUFFER_SIZE)
|
2010-10-20 02:17:16 +00:00
|
|
|
{
|
|
|
|
// Wrap around
|
2019-02-15 01:59:50 +00:00
|
|
|
m_current_buffer = (m_current_buffer + 1) % BUFFER_COUNT;
|
2014-10-25 17:04:33 +00:00
|
|
|
cursor = 0;
|
2012-10-20 13:22:15 +00:00
|
|
|
MapType = D3D11_MAP_WRITE_DISCARD;
|
2010-10-20 02:17:16 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
*out_base_vertex = vertex_stride > 0 ? (cursor / vertex_stride) : 0;
|
|
|
|
*out_base_index = (cursor + vertexBufferSize) / sizeof(u16);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
D3D::context->Map(m_buffers[m_current_buffer].Get(), 0, MapType, 0, &map);
|
2014-10-25 17:04:33 +00:00
|
|
|
u8* mappedData = reinterpret_cast<u8*>(map.pData);
|
2018-11-27 07:16:53 +00:00
|
|
|
if (vertexBufferSize > 0)
|
|
|
|
std::memcpy(mappedData + cursor, m_base_buffer_pointer, vertexBufferSize);
|
|
|
|
if (indexBufferSize > 0)
|
2019-02-15 01:59:50 +00:00
|
|
|
std::memcpy(mappedData + cursor + vertexBufferSize, m_cpu_index_buffer.data(), indexBufferSize);
|
2019-03-09 13:31:37 +00:00
|
|
|
D3D::context->Unmap(m_buffers[m_current_buffer].Get(), 0);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
m_buffer_cursor = cursor + totalBufferSize;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-07-11 03:34:50 +00:00
|
|
|
ADDSTAT(g_stats.this_frame.bytes_vertex_streamed, vertexBufferSize);
|
|
|
|
ADDSTAT(g_stats.this_frame.bytes_index_streamed, indexBufferSize);
|
2018-11-27 07:16:53 +00:00
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
D3D::stateman->SetVertexBuffer(m_buffers[m_current_buffer].Get(), vertex_stride, 0);
|
|
|
|
D3D::stateman->SetIndexBuffer(m_buffers[m_current_buffer].Get());
|
2010-10-20 02:17:16 +00:00
|
|
|
}
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
void VertexManager::UploadUniforms()
|
2010-10-20 02:17:16 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
if (VertexShaderManager::dirty)
|
|
|
|
{
|
2019-03-09 13:31:37 +00:00
|
|
|
UpdateConstantBuffer(m_vertex_constant_buffer.Get(), &VertexShaderManager::constants,
|
2018-11-27 07:16:53 +00:00
|
|
|
sizeof(VertexShaderConstants));
|
|
|
|
VertexShaderManager::dirty = false;
|
|
|
|
}
|
|
|
|
if (GeometryShaderManager::dirty)
|
|
|
|
{
|
2019-03-09 13:31:37 +00:00
|
|
|
UpdateConstantBuffer(m_geometry_constant_buffer.Get(), &GeometryShaderManager::constants,
|
2018-11-27 07:16:53 +00:00
|
|
|
sizeof(GeometryShaderConstants));
|
|
|
|
GeometryShaderManager::dirty = false;
|
|
|
|
}
|
2022-12-27 16:42:02 +00:00
|
|
|
|
|
|
|
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
|
|
|
if (pixel_shader_manager.dirty)
|
2018-11-27 07:16:53 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
UpdateConstantBuffer(m_pixel_constant_buffer.Get(), &pixel_shader_manager.constants,
|
2018-11-27 07:16:53 +00:00
|
|
|
sizeof(PixelShaderConstants));
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.dirty = false;
|
2018-11-27 07:16:53 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-03-09 13:31:37 +00:00
|
|
|
D3D::stateman->SetPixelConstants(
|
|
|
|
m_pixel_constant_buffer.Get(),
|
|
|
|
g_ActiveConfig.bEnablePixelLighting ? m_vertex_constant_buffer.Get() : nullptr);
|
|
|
|
D3D::stateman->SetVertexConstants(m_vertex_constant_buffer.Get());
|
|
|
|
D3D::stateman->SetGeometryConstants(m_geometry_constant_buffer.Get());
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
2018-11-27 07:16:53 +00:00
|
|
|
} // namespace DX11
|