diff --git a/Source/Core/VideoBackends/Metal/MTLStateTracker.h b/Source/Core/VideoBackends/Metal/MTLStateTracker.h index 3e7bac832d..2ec2e2ae27 100644 --- a/Source/Core/VideoBackends/Metal/MTLStateTracker.h +++ b/Source/Core/VideoBackends/Metal/MTLStateTracker.h @@ -83,7 +83,7 @@ public: void SetTexture(u32 idx, id texture); void SetSampler(u32 idx, const SamplerState& sampler); void SetComputeTexture(const Texture* texture); - void InvalidateUniforms(bool vertex, bool fragment); + void InvalidateUniforms(bool vertex, bool geometry, bool fragment); void SetUtilityUniform(const void* buffer, size_t size); void SetTexelBuffer(id buffer, u32 offset0, u32 offset1); void SetVerticesAndIndices(id vertices, id indices); @@ -180,6 +180,7 @@ private: { // clang-format off bool has_gx_vs_uniform : 1; + bool has_gx_gs_uniform : 1; bool has_gx_ps_uniform : 1; bool has_utility_vs_uniform : 1; bool has_utility_ps_uniform : 1; diff --git a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm index 0004c81089..e25e33fe02 100644 --- a/Source/Core/VideoBackends/Metal/MTLStateTracker.mm +++ b/Source/Core/VideoBackends/Metal/MTLStateTracker.mm @@ -15,6 +15,7 @@ #include "VideoBackends/Metal/MTLTexture.h" #include "VideoBackends/Metal/MTLUtil.h" +#include "VideoCommon/GeometryShaderManager.h" #include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexShaderManager.h" @@ -462,9 +463,10 @@ void Metal::StateTracker::UnbindTexture(id texture) } } -void Metal::StateTracker::InvalidateUniforms(bool vertex, bool fragment) +void Metal::StateTracker::InvalidateUniforms(bool vertex, bool geometry, bool fragment) { m_flags.has_gx_vs_uniform &= !vertex; + m_flags.has_gx_gs_uniform &= !geometry; m_flags.has_gx_ps_uniform &= !fragment; } @@ -722,6 +724,14 @@ void Metal::StateTracker::PrepareRender() ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, Align(sizeof(VertexShaderConstants), AlignMask::Uniform)); } + if (!m_flags.has_gx_gs_uniform && pipe->UsesVertexBuffer(2)) + { + m_flags.has_gx_gs_uniform = true; + [m_current_render_encoder setVertexBytes:&GeometryShaderManager::constants + length:sizeof(GeometryShaderConstants) + atIndex:2]; + ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(GeometryShaderConstants)); + } if (!m_flags.has_gx_ps_uniform) { m_flags.has_gx_ps_uniform = true; diff --git a/Source/Core/VideoBackends/Metal/MTLUtil.mm b/Source/Core/VideoBackends/Metal/MTLUtil.mm index 30eb305de3..aa379c0851 100644 --- a/Source/Core/VideoBackends/Metal/MTLUtil.mm +++ b/Source/Core/VideoBackends/Metal/MTLUtil.mm @@ -75,6 +75,7 @@ void Metal::Util::PopulateBackendInfo(VideoConfig* config) // Metal requires multisample resolve to be done on a render pass config->backend_info.bSupportsPartialMultisampleResolve = false; config->backend_info.bSupportsDynamicVertexLoader = true; + config->backend_info.bSupportsVSLinePointExpand = true; } void Metal::Util::PopulateBackendInfoAdapters(VideoConfig* config, @@ -427,6 +428,7 @@ std::optional Metal::Util::TranslateShaderToMSL(ShaderStage stage, static const spirv_cross::MSLResourceBinding resource_bindings[] = { MakeResourceBinding(spv::ExecutionModelVertex, 0, 0, 1, 0, 0), // vs/ubo MakeResourceBinding(spv::ExecutionModelVertex, 0, 1, 1, 0, 0), // vs/ubo + MakeResourceBinding(spv::ExecutionModelVertex, 0, 2, 2, 0, 0), // vs/ubo MakeResourceBinding(spv::ExecutionModelVertex, 2, 1, 0, 0, 0), // vs/ssbo MakeResourceBinding(spv::ExecutionModelFragment, 0, 0, 0, 0, 0), // vs/ubo MakeResourceBinding(spv::ExecutionModelFragment, 0, 1, 1, 0, 0), // vs/ubo diff --git a/Source/Core/VideoBackends/Metal/MTLVertexManager.mm b/Source/Core/VideoBackends/Metal/MTLVertexManager.mm index 8fb3e25de4..6cfad2d2f8 100644 --- a/Source/Core/VideoBackends/Metal/MTLVertexManager.mm +++ b/Source/Core/VideoBackends/Metal/MTLVertexManager.mm @@ -5,6 +5,7 @@ #include "VideoBackends/Metal/MTLStateTracker.h" +#include "VideoCommon/GeometryShaderManager.h" #include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexShaderManager.h" @@ -88,7 +89,9 @@ void Metal::VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 void Metal::VertexManager::UploadUniforms() { - g_state_tracker->InvalidateUniforms(VertexShaderManager::dirty, PixelShaderManager::dirty); + g_state_tracker->InvalidateUniforms(VertexShaderManager::dirty, GeometryShaderManager::dirty, + PixelShaderManager::dirty); VertexShaderManager::dirty = false; + GeometryShaderManager::dirty = false; PixelShaderManager::dirty = false; }