diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props
index f7f7606982..ddb2cd86e7 100644
--- a/Source/Core/DolphinLib.props
+++ b/Source/Core/DolphinLib.props
@@ -635,6 +635,7 @@
+
diff --git a/Source/Core/VideoBackends/D3D/D3DState.cpp b/Source/Core/VideoBackends/D3D/D3DState.cpp
index 66ccec2416..8ab1991e90 100644
--- a/Source/Core/VideoBackends/D3D/D3DState.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DState.cpp
@@ -205,7 +205,7 @@ u32 StateManager::UnsetTexture(ID3D11ShaderResourceView* srv)
{
u32 mask = 0;
- for (u32 index = 0; index < 8; ++index)
+ for (u32 index = 0; index < VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; ++index)
{
if (m_current.textures[index] == srv)
{
diff --git a/Source/Core/VideoBackends/D3D/D3DState.h b/Source/Core/VideoBackends/D3D/D3DState.h
index 795e7a0432..812fc778ae 100644
--- a/Source/Core/VideoBackends/D3D/D3DState.h
+++ b/Source/Core/VideoBackends/D3D/D3DState.h
@@ -12,6 +12,7 @@
#include "Common/BitField.h"
#include "Common/CommonTypes.h"
#include "VideoBackends/D3D/D3DBase.h"
+#include "VideoCommon/Constants.h"
#include "VideoCommon/RenderState.h"
namespace DX11
@@ -263,8 +264,8 @@ private:
struct Resources
{
- std::array textures;
- std::array samplers;
+ std::array textures;
+ std::array samplers;
std::array pixelConstants;
ID3D11Buffer* vertexConstants;
ID3D11Buffer* geometryConstants;
diff --git a/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp b/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp
index b3ade2e5d3..e86579b87f 100644
--- a/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp
+++ b/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp
@@ -33,8 +33,7 @@ Gfx::Gfx(std::unique_ptr swap_chain, float backbuffer_scale)
{
m_state.root_signature = g_dx_context->GetGXRootSignature();
- // Textures must be populated with null descriptors, since we copy directly from this array.
- for (u32 i = 0; i < MAX_TEXTURES; i++)
+ for (u32 i = 0; i < VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; i++)
{
m_state.textures[i].ptr = g_dx_context->GetNullSRVDescriptor().cpu_handle.ptr;
m_state.samplers.states[i] = RenderState::GetPointSamplerState();
@@ -301,7 +300,7 @@ void Gfx::UnbindTexture(const AbstractTexture* texture)
{
const auto srv_shadow_descriptor =
static_cast(texture)->GetSRVDescriptor().cpu_handle;
- for (u32 i = 0; i < MAX_TEXTURES; i++)
+ for (u32 i = 0; i < VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; i++)
{
if (m_state.textures[i].ptr == srv_shadow_descriptor.ptr)
{
@@ -666,15 +665,17 @@ void Gfx::UpdateDescriptorTables()
bool Gfx::UpdateSRVDescriptorTable()
{
- static constexpr std::array src_sizes = {1, 1, 1, 1, 1, 1, 1, 1};
+ static constexpr std::array src_sizes = {
+ 1, 1, 1, 1, 1, 1, 1, 1};
DescriptorHandle dst_base_handle;
const UINT dst_handle_sizes = 8;
- if (!g_dx_context->GetDescriptorAllocator()->Allocate(MAX_TEXTURES, &dst_base_handle))
+ if (!g_dx_context->GetDescriptorAllocator()->Allocate(VideoCommon::MAX_PIXEL_SHADER_SAMPLERS,
+ &dst_base_handle))
return false;
g_dx_context->GetDevice()->CopyDescriptors(
- 1, &dst_base_handle.cpu_handle, &dst_handle_sizes, MAX_TEXTURES, m_state.textures.data(),
- src_sizes.data(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
+ 1, &dst_base_handle.cpu_handle, &dst_handle_sizes, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS,
+ m_state.textures.data(), src_sizes.data(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
m_state.srv_descriptor_base = dst_base_handle.gpu_handle;
m_dirty_bits = (m_dirty_bits & ~DirtyState_Textures) | DirtyState_SRV_Descriptor;
return true;
diff --git a/Source/Core/VideoBackends/D3D12/D3D12Gfx.h b/Source/Core/VideoBackends/D3D12/D3D12Gfx.h
index 95774dd71d..9855ae7ca6 100644
--- a/Source/Core/VideoBackends/D3D12/D3D12Gfx.h
+++ b/Source/Core/VideoBackends/D3D12/D3D12Gfx.h
@@ -7,6 +7,7 @@
#include "VideoBackends/D3D12/DescriptorAllocator.h"
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
#include "VideoCommon/AbstractGfx.h"
+#include "VideoCommon/Constants.h"
namespace DX12
{
@@ -96,7 +97,6 @@ protected:
void OnConfigChanged(u32 bits) override;
private:
- static const u32 MAX_TEXTURES = 8;
static const u32 NUM_CONSTANT_BUFFERS = 3;
// Dirty bits
@@ -158,7 +158,7 @@ private:
ID3D12RootSignature* root_signature = nullptr;
DXShader* compute_shader = nullptr;
std::array constant_buffers = {};
- std::array textures = {};
+ std::array textures = {};
D3D12_CPU_DESCRIPTOR_HANDLE vs_srv = {};
D3D12_CPU_DESCRIPTOR_HANDLE ps_uav = {};
SamplerStateSet samplers = {};
diff --git a/Source/Core/VideoBackends/D3D12/DX12Context.cpp b/Source/Core/VideoBackends/D3D12/DX12Context.cpp
index e0fd41e4f0..8343e39a6e 100644
--- a/Source/Core/VideoBackends/D3D12/DX12Context.cpp
+++ b/Source/Core/VideoBackends/D3D12/DX12Context.cpp
@@ -334,8 +334,8 @@ bool DXContext::CreateGXRootSignature()
{
// GX:
// - 3 constant buffers (bindings 0-2), 0/1 visible in PS, 2 visible in VS, 1 visible in GS.
- // - 8 textures (visible in PS).
- // - 8 samplers (visible in PS).
+ // - VideoCommon::MAX_PIXEL_SHADER_SAMPLERS textures (visible in PS).
+ // - VideoCommon::MAX_PIXEL_SHADER_SAMPLERS samplers (visible in PS).
// - 1 UAV (visible in PS).
std::array params;
@@ -344,10 +344,10 @@ bool DXContext::CreateGXRootSignature()
SetRootParamCBV(¶ms[param_count], 0, D3D12_SHADER_VISIBILITY_PIXEL);
param_count++;
SetRootParamTable(¶ms[param_count], &ranges[param_count], D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0,
- 8, D3D12_SHADER_VISIBILITY_PIXEL);
+ VideoCommon::MAX_PIXEL_SHADER_SAMPLERS, D3D12_SHADER_VISIBILITY_PIXEL);
param_count++;
SetRootParamTable(¶ms[param_count], &ranges[param_count], D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER,
- 0, 8, D3D12_SHADER_VISIBILITY_PIXEL);
+ 0, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS, D3D12_SHADER_VISIBILITY_PIXEL);
param_count++;
SetRootParamCBV(¶ms[param_count], 0, D3D12_SHADER_VISIBILITY_VERTEX);
param_count++;
diff --git a/Source/Core/VideoBackends/D3D12/DescriptorAllocator.cpp b/Source/Core/VideoBackends/D3D12/DescriptorAllocator.cpp
index bd50b97d87..d77d7f454d 100644
--- a/Source/Core/VideoBackends/D3D12/DescriptorAllocator.cpp
+++ b/Source/Core/VideoBackends/D3D12/DescriptorAllocator.cpp
@@ -86,23 +86,23 @@ bool SamplerAllocator::GetGroupHandle(const SamplerStateSet& sss,
// Allocate a group of descriptors.
DescriptorHandle allocation;
- if (!Allocate(SamplerStateSet::NUM_SAMPLERS_PER_GROUP, &allocation))
+ if (!Allocate(VideoCommon::MAX_PIXEL_SHADER_SAMPLERS, &allocation))
return false;
// Lookup sampler handles from global cache.
- std::array source_handles;
- for (u32 i = 0; i < SamplerStateSet::NUM_SAMPLERS_PER_GROUP; i++)
+ std::array source_handles;
+ for (u32 i = 0; i < VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; i++)
{
if (!g_dx_context->GetSamplerHeapManager().Lookup(sss.states[i], &source_handles[i]))
return false;
}
// Copy samplers from the sampler heap.
- static constexpr std::array source_sizes = {
+ static constexpr std::array source_sizes = {
{1, 1, 1, 1, 1, 1, 1, 1}};
g_dx_context->GetDevice()->CopyDescriptors(
- 1, &allocation.cpu_handle, &SamplerStateSet::NUM_SAMPLERS_PER_GROUP,
- SamplerStateSet::NUM_SAMPLERS_PER_GROUP, source_handles.data(), source_sizes.data(),
+ 1, &allocation.cpu_handle, &VideoCommon::MAX_PIXEL_SHADER_SAMPLERS,
+ VideoCommon::MAX_PIXEL_SHADER_SAMPLERS, source_handles.data(), source_sizes.data(),
D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
*handle = allocation.gpu_handle;
m_sampler_map.emplace(sss, allocation.gpu_handle);
diff --git a/Source/Core/VideoBackends/D3D12/DescriptorAllocator.h b/Source/Core/VideoBackends/D3D12/DescriptorAllocator.h
index 278df058a1..bdc5f3996b 100644
--- a/Source/Core/VideoBackends/D3D12/DescriptorAllocator.h
+++ b/Source/Core/VideoBackends/D3D12/DescriptorAllocator.h
@@ -5,6 +5,7 @@
#include