diff --git a/src/shader_recompiler/backend/msl/emit_msl_context_get_set.cpp b/src/shader_recompiler/backend/msl/emit_msl_context_get_set.cpp index e51d063a32..b92583ec5c 100644 --- a/src/shader_recompiler/backend/msl/emit_msl_context_get_set.cpp +++ b/src/shader_recompiler/backend/msl/emit_msl_context_get_set.cpp @@ -215,7 +215,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, case IR::Attribute::PositionW: { const bool is_array{IsInputArray(ctx.stage)}; const auto input_decorator{is_array ? fmt::format("gl_in[{}].", vertex) : ""}; - ctx.AddF32("{}={}{}.{};", inst, input_decorator, ctx.position_name, swizzle); + ctx.AddF32("{}={}{}.{};", inst, input_decorator, "__out.position", swizzle); break; } case IR::Attribute::PointSpriteS: @@ -326,7 +326,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val case IR::Attribute::PositionY: case IR::Attribute::PositionZ: case IR::Attribute::PositionW: - ctx.Add("gl_Position.{}={};", swizzle, value); + ctx.Add("__out.position.{}={};", swizzle, value); break; case IR::Attribute::ClipDistance0: case IR::Attribute::ClipDistance1: @@ -337,7 +337,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val case IR::Attribute::ClipDistance6: case IR::Attribute::ClipDistance7: { const u32 index{static_cast(attr) - static_cast(IR::Attribute::ClipDistance0)}; - ctx.Add("gl_ClipDistance[{}]={};", index, value); + ctx.Add("IMPLEMENT(gl_ClipDistance)[{}]={};", index, value); break; } default: diff --git a/src/shader_recompiler/backend/msl/emit_msl_special.cpp b/src/shader_recompiler/backend/msl/emit_msl_special.cpp index 1e32973686..86a30cd13e 100644 --- a/src/shader_recompiler/backend/msl/emit_msl_special.cpp +++ b/src/shader_recompiler/backend/msl/emit_msl_special.cpp @@ -9,16 +9,18 @@ namespace Shader::Backend::MSL { namespace { +// TODO std::string_view OutputVertexIndex(EmitContext& ctx) { - return ctx.stage == Stage::TessellationControl ? "[gl_InvocationID]" : ""; + return ctx.stage == Stage::TessellationControl ? "[IMPLEMENT(gl_InvocationID)]" : ""; } void InitializeOutputVaryings(EmitContext& ctx) { if (ctx.uses_geometry_passthrough) { return; } + ctx.Add("__Output __out;"); if (ctx.stage == Stage::VertexB || ctx.stage == Stage::Geometry) { - ctx.Add("gl_Position=vec4(0,0,0,1);"); + ctx.Add("__out.position=vec4(0,0,0,1);"); } for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { if (!ctx.info.stores.Generic(index)) { @@ -29,7 +31,7 @@ void InitializeOutputVaryings(EmitContext& ctx) { size_t element{}; while (element < info_array.size()) { const auto& info{info_array.at(element)}; - const auto varying_name{fmt::format("{}{}", info.name, output_decorator)}; + const auto varying_name{fmt::format("__out.{}{}", info.name, output_decorator)}; switch (info.num_components) { case 1: { const char value{element == 3 ? '1' : '0'}; @@ -39,15 +41,15 @@ void InitializeOutputVaryings(EmitContext& ctx) { case 2: case 3: if (element + info.num_components < 4) { - ctx.Add("{}=vec{}(0);", varying_name, info.num_components); + ctx.Add("{}=vec(0);", varying_name, info.num_components); } else { // last element is the w component, must be initialized to 1 const auto zeros{info.num_components == 3 ? "0,0," : "0,"}; - ctx.Add("{}=vec{}({}1);", varying_name, info.num_components, zeros); + ctx.Add("{}=vec({}1);", varying_name, info.num_components, zeros); } break; case 4: - ctx.Add("{}=vec4(0,0,0,1);", varying_name); + ctx.Add("{}=float4(0,0,0,1);", varying_name); break; default: break; diff --git a/src/shader_recompiler/backend/msl/msl_emit_context.cpp b/src/shader_recompiler/backend/msl/msl_emit_context.cpp index 9a8c767afb..e6e18a136c 100644 --- a/src/shader_recompiler/backend/msl/msl_emit_context.cpp +++ b/src/shader_recompiler/backend/msl/msl_emit_context.cpp @@ -253,7 +253,6 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile break; case Stage::Fragment: stage_name = "fs"; - position_name = "gl_FragCoord"; if (runtime_info.force_early_z) { header += "layout(early_fragment_tests)in;"; } @@ -461,7 +460,7 @@ void EmitContext::DefineHelperFunctions() { const auto position_idx{is_array ? "gl_in[vertex]." : ""}; func += fmt::format("case {}:return {}{}[masked_index];", static_cast(IR::Attribute::PositionX) >> 2, position_idx, - position_name); + "__out.position"); } const u32 base_attribute_value = static_cast(IR::Attribute::Generic0X) >> 2; for (u32 index = 0; index < IR::NUM_GENERICS; ++index) { diff --git a/src/shader_recompiler/backend/msl/msl_emit_context.h b/src/shader_recompiler/backend/msl/msl_emit_context.h index 1a6b5d9769..6753d875e9 100644 --- a/src/shader_recompiler/backend/msl/msl_emit_context.h +++ b/src/shader_recompiler/backend/msl/msl_emit_context.h @@ -144,7 +144,6 @@ public: Stage stage{}; std::string_view stage_name = "invalid"; - std::string_view position_name = "gl_Position"; std::vector texture_buffers; std::vector image_buffers; diff --git a/src/video_core/renderer_metal/mtl_pipeline_cache.cpp b/src/video_core/renderer_metal/mtl_pipeline_cache.cpp index 2f4bfd2bd1..e5c4acfded 100644 --- a/src/video_core/renderer_metal/mtl_pipeline_cache.cpp +++ b/src/video_core/renderer_metal/mtl_pipeline_cache.cpp @@ -277,6 +277,8 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( LOG_ERROR(Render_Metal, "failed to create library: {}", error->description()->cString(NS::ASCIIStringEncoding)); // HACK + std::cout << error->description()->cString(NS::ASCIIStringEncoding) << std::endl; + // HACK throw; }