summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorOatmealDome <OatmealDome@users.noreply.github.com>2023-04-18 22:11:06 +0200
committerGitHub <noreply@github.com>2023-04-18 22:11:06 +0200
commit8a355dbbd7a37629c5844461bf1796a86f1510f6 (patch)
tree9775598150f47190592a5b20eafecafdb5d9ec33 /Source/Core
parenta239af162d99d5fc7abaf629822852c0fd55a7af (diff)
parented177bdbd7c77df9c34c2670c329415c998faa59 (diff)
Merge pull request #11708 from TellowKrinkle/MetalMaxPixSamplers
VideoBackends:Metal: Use max pixel samplers constant
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/Metal/MTLStateTracker.h13
-rw-r--r--Source/Core/VideoBackends/Metal/MTLStateTracker.mm12
2 files changed, 14 insertions, 11 deletions
diff --git a/Source/Core/VideoBackends/Metal/MTLStateTracker.h b/Source/Core/VideoBackends/Metal/MTLStateTracker.h
index f425cd2884..2357322e4c 100644
--- a/Source/Core/VideoBackends/Metal/MTLStateTracker.h
+++ b/Source/Core/VideoBackends/Metal/MTLStateTracker.h
@@ -17,6 +17,7 @@
#include "VideoBackends/Metal/MTLTexture.h"
#include "VideoBackends/Metal/MTLUtil.h"
+#include "VideoCommon/Constants.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/PerfQueryBase.h"
@@ -194,6 +195,8 @@ private:
// MARK: State
u8 m_dirty_textures;
u8 m_dirty_samplers;
+ static_assert(sizeof(m_dirty_textures) * 8 >= VideoCommon::MAX_PIXEL_SHADER_SAMPLERS,
+ "Make these bigger");
union Flags
{
struct
@@ -249,11 +252,11 @@ private:
Util::Viewport viewport;
const Pipeline* render_pipeline = nullptr;
const ComputePipeline* compute_pipeline = nullptr;
- std::array<id<MTLTexture>, 8> textures = {};
- std::array<id<MTLSamplerState>, 8> samplers = {};
- std::array<float, 8> sampler_min_lod;
- std::array<float, 8> sampler_max_lod;
- std::array<SamplerState, 8> sampler_states;
+ std::array<id<MTLTexture>, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> textures = {};
+ std::array<id<MTLSamplerState>, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> samplers = {};
+ std::array<float, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> sampler_min_lod;
+ std::array<float, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> sampler_max_lod;
+ std::array<SamplerState, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> sampler_states;
const Texture* compute_texture = nullptr;
std::unique_ptr<u8[]> utility_uniform;
u32 utility_uniform_size = 0;
diff --git a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm
index 53462b9bdf..2769910d88 100644
--- a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm
+++ b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm
@@ -371,8 +371,8 @@ void Metal::StateTracker::BeginRenderPass(MTLRenderPassDescriptor* descriptor)
m_current.cull_mode = MTLCullModeNone;
m_current.perf_query_group = static_cast<PerfQueryGroup>(-1);
m_flags.NewEncoder();
- m_dirty_samplers = 0xff;
- m_dirty_textures = 0xff;
+ m_dirty_samplers = (1 << VideoCommon::MAX_PIXEL_SHADER_SAMPLERS) - 1;
+ m_dirty_textures = (1 << VideoCommon::MAX_PIXEL_SHADER_SAMPLERS) - 1;
CheckScissor();
CheckViewport();
ASSERT_MSG(VIDEO, m_current_render_encoder, "Failed to create render encoder!");
@@ -386,8 +386,8 @@ void Metal::StateTracker::BeginComputePass()
if (m_manual_buffer_upload)
[m_current_compute_encoder waitForFence:m_fence];
m_flags.NewEncoder();
- m_dirty_samplers = 0xff;
- m_dirty_textures = 0xff;
+ m_dirty_samplers = (1 << VideoCommon::MAX_PIXEL_SHADER_SAMPLERS) - 1;
+ m_dirty_textures = (1 << VideoCommon::MAX_PIXEL_SHADER_SAMPLERS) - 1;
}
void Metal::StateTracker::EndRenderPass()
@@ -801,13 +801,13 @@ void Metal::StateTracker::PrepareRender()
if (m_state.vertices)
SetVertexBufferNow(0, m_state.vertices, 0);
}
- if (u8 dirty = m_dirty_textures & pipe->GetTextures())
+ if (u32 dirty = m_dirty_textures & pipe->GetTextures())
{
m_dirty_textures &= ~pipe->GetTextures();
NSRange range = RangeOfBits(dirty);
[enc setFragmentTextures:&m_state.textures[range.location] withRange:range];
}
- if (u8 dirty = m_dirty_samplers & pipe->GetSamplers())
+ if (u32 dirty = m_dirty_samplers & pipe->GetSamplers())
{
m_dirty_samplers &= ~pipe->GetSamplers();
NSRange range = RangeOfBits(dirty);