VERY experimental Nintendo Switch 2 emulator
C++
glsl: Implement more instructions used by SMO
ameerj3795c56db6c3
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cppindex c20747819b..4bb20b8fad 100644--- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp+++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp@@ -148,6 +148,10 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,throw NotImplementedException("Get Position for stage {}", ctx.stage);}break;+ case IR::Attribute::PointSpriteS:+ case IR::Attribute::PointSpriteT:+ ctx.AddF32("{}=gl_PointCoord.{};", inst, swizzle);+ break;case IR::Attribute::InstanceId:ctx.AddF32("{}=intBitsToFloat(gl_InstanceID);", inst);break;@@ -174,7 +178,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val}switch (attr) {case IR::Attribute::PointSize:- ctx.Add("gl_Pointsize={};", value);+ ctx.Add("gl_PointSize={};", value);break;case IR::Attribute::PositionX:case IR::Attribute::PositionY:diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_convert.cppindex 2ecfc29933..85d07b4de2 100644--- a/src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp+++ b/src/shader_recompiler/backend/glsl/emit_glsl_convert.cpp@@ -16,7 +16,7 @@ void EmitConvertS16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Ivoid EmitConvertS16F32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,[[maybe_unused]] std::string_view value) {- throw NotImplementedException("GLSL Instruction");+ ctx.AddS32("{}=int(float({}))&0xffff;", inst, value);}void EmitConvertS16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cppindex d1f7c5d914..e63e3f2bde 100644--- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp+++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp@@ -376,7 +376,9 @@ void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,[[maybe_unused]] const IR::Value& index,[[maybe_unused]] std::string_view coords) {- throw NotImplementedException("GLSL Instruction");+ const auto info{inst.Flags<IR::TextureInstInfo>()};+ const auto texture{Texture(ctx, info, index)};+ return ctx.AddF32x4("{}=vec4(textureQueryLod({},{}),0.0,0.0);", inst, texture, coords);}void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.hindex 07408d9e9b..a1806b7f51 100644--- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h+++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h@@ -86,10 +86,10 @@ void EmitSetZFlag(EmitContext& ctx);void EmitSetSFlag(EmitContext& ctx);void EmitSetCFlag(EmitContext& ctx);void EmitSetOFlag(EmitContext& ctx);-void EmitWorkgroupId(EmitContext& ctx);+void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst);void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst);-void EmitInvocationId(EmitContext& ctx);-void EmitSampleId(EmitContext& ctx);+void EmitInvocationId(EmitContext& ctx, IR::Inst& inst);+void EmitSampleId(EmitContext& ctx, IR::Inst& inst);void EmitIsHelperInvocation(EmitContext& ctx);void EmitYDirection(EmitContext& ctx, IR::Inst& inst);void EmitLoadLocal(EmitContext& ctx, std::string_view word_offset);diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cppindex b8f95bd368..9af9ebeaca 100644--- a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp+++ b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp@@ -203,15 +203,15 @@ void EmitSetOFlag(EmitContext& ctx) {NotImplemented();}-void EmitWorkgroupId(EmitContext& ctx) {- NotImplemented();+void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst) {+ ctx.AddU32x3("{}=gl_WorkGroupID;", inst);}-void EmitInvocationId(EmitContext& ctx) {+void EmitInvocationId(EmitContext& ctx, IR::Inst& inst) {NotImplemented();}-void EmitSampleId(EmitContext& ctx) {+void EmitSampleId(EmitContext& ctx, IR::Inst& inst) {NotImplemented();}