diff options
| author | 2021-06-10 00:01:56 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:37 -0400 | |
| commit | e7c8f8911f38b29c0725b76db75ce6d6d857c5f9 (patch) | |
| tree | 434985028b041c36a6e294f834029eb7a1997794 /src | |
| parent | glsl: Add gl_PerVertex in for GS (diff) | |
| download | yuzu-e7c8f8911f38b29c0725b76db75ce6d6d857c5f9.tar.gz yuzu-e7c8f8911f38b29c0725b76db75ce6d6d857c5f9.tar.xz yuzu-e7c8f8911f38b29c0725b76db75ce6d6d857c5f9.zip | |
glsl: Implement SampleId and SetSampleMask
plus some minor refactoring of implementations
Diffstat (limited to 'src')
3 files changed, 35 insertions, 30 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index fdbe2986c..484548467 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -256,6 +256,12 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 256 | if (runtime_info.force_early_z) { | 256 | if (runtime_info.force_early_z) { |
| 257 | header += "layout(early_fragment_tests)in;"; | 257 | header += "layout(early_fragment_tests)in;"; |
| 258 | } | 258 | } |
| 259 | if (info.uses_sample_id) { | ||
| 260 | header += "in int gl_SampleID;"; | ||
| 261 | } | ||
| 262 | if (info.stores_sample_mask) { | ||
| 263 | header += "out int gl_SampleMask[];"; | ||
| 264 | } | ||
| 259 | break; | 265 | break; |
| 260 | case Stage::Compute: | 266 | case Stage::Compute: |
| 261 | stage_name = "cs"; | 267 | stage_name = "cs"; |
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.cpp index c9a2ceb3d..0546c1c81 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 | |||
| @@ -239,7 +239,6 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | |||
| 239 | ctx.AddF32("{}=itof(gl_FrontFacing?-1:0);", inst); | 239 | ctx.AddF32("{}=itof(gl_FrontFacing?-1:0);", inst); |
| 240 | break; | 240 | break; |
| 241 | default: | 241 | default: |
| 242 | fmt::print("Get attribute {}", attr); | ||
| 243 | throw NotImplementedException("Get attribute {}", attr); | 242 | throw NotImplementedException("Get attribute {}", attr); |
| 244 | } | 243 | } |
| 245 | } | 244 | } |
| @@ -397,10 +396,39 @@ void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, std::string_vi | |||
| 397 | ctx.Add("frag_color{}.{}={};", index, swizzle, value); | 396 | ctx.Add("frag_color{}.{}={};", index, swizzle, value); |
| 398 | } | 397 | } |
| 399 | 398 | ||
| 399 | void EmitSetSampleMask(EmitContext& ctx, std::string_view value) { | ||
| 400 | ctx.Add("gl_SampleMask[0]=int({})", value); | ||
| 401 | } | ||
| 402 | |||
| 403 | void EmitSetFragDepth(EmitContext& ctx, std::string_view value) { | ||
| 404 | ctx.Add("gl_FragDepth={};", value); | ||
| 405 | } | ||
| 406 | |||
| 400 | void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst) { | 407 | void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst) { |
| 401 | ctx.AddU32x3("{}=gl_LocalInvocationID;", inst); | 408 | ctx.AddU32x3("{}=gl_LocalInvocationID;", inst); |
| 402 | } | 409 | } |
| 403 | 410 | ||
| 411 | void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst) { | ||
| 412 | ctx.AddU32x3("{}=gl_WorkGroupID;", inst); | ||
| 413 | } | ||
| 414 | |||
| 415 | void EmitInvocationId(EmitContext& ctx, IR::Inst& inst) { | ||
| 416 | ctx.AddU32("{}=uint(gl_InvocationID);", inst); | ||
| 417 | } | ||
| 418 | |||
| 419 | void EmitSampleId(EmitContext& ctx, IR::Inst& inst) { | ||
| 420 | ctx.AddU32("{}=uint(gl_SampleID);", inst); | ||
| 421 | } | ||
| 422 | |||
| 423 | void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst) { | ||
| 424 | ctx.AddU1("{}=gl_HelperInvocation;", inst); | ||
| 425 | } | ||
| 426 | |||
| 427 | void EmitYDirection(EmitContext& ctx, IR::Inst& inst) { | ||
| 428 | ctx.uses_y_direction = true; | ||
| 429 | ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst); | ||
| 430 | } | ||
| 431 | |||
| 404 | void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset) { | 432 | void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset) { |
| 405 | ctx.AddU32("{}=lmem[{}];", inst, word_offset); | 433 | ctx.AddU32("{}=lmem[{}];", inst, word_offset); |
| 406 | } | 434 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp index b292db9d4..f17a07955 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp | |||
| @@ -124,14 +124,6 @@ void EmitGetIndirectBranchVariable(EmitContext& ctx) { | |||
| 124 | NotImplemented(); | 124 | NotImplemented(); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | void EmitSetSampleMask(EmitContext& ctx, std::string_view value) { | ||
| 128 | NotImplemented(); | ||
| 129 | } | ||
| 130 | |||
| 131 | void EmitSetFragDepth(EmitContext& ctx, std::string_view value) { | ||
| 132 | ctx.Add("gl_FragDepth={};", value); | ||
| 133 | } | ||
| 134 | |||
| 135 | void EmitGetZFlag(EmitContext& ctx) { | 127 | void EmitGetZFlag(EmitContext& ctx) { |
| 136 | NotImplemented(); | 128 | NotImplemented(); |
| 137 | } | 129 | } |
| @@ -164,27 +156,6 @@ void EmitSetOFlag(EmitContext& ctx) { | |||
| 164 | NotImplemented(); | 156 | NotImplemented(); |
| 165 | } | 157 | } |
| 166 | 158 | ||
| 167 | void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst) { | ||
| 168 | ctx.AddU32x3("{}=gl_WorkGroupID;", inst); | ||
| 169 | } | ||
| 170 | |||
| 171 | void EmitInvocationId(EmitContext& ctx, IR::Inst& inst) { | ||
| 172 | ctx.AddU32("{}=uint(gl_InvocationID);", inst); | ||
| 173 | } | ||
| 174 | |||
| 175 | void EmitSampleId(EmitContext& ctx, IR::Inst& inst) { | ||
| 176 | NotImplemented(); | ||
| 177 | } | ||
| 178 | |||
| 179 | void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst) { | ||
| 180 | ctx.AddU1("{}=gl_HelperInvocation;", inst); | ||
| 181 | } | ||
| 182 | |||
| 183 | void EmitYDirection(EmitContext& ctx, IR::Inst& inst) { | ||
| 184 | ctx.uses_y_direction = true; | ||
| 185 | ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst); | ||
| 186 | } | ||
| 187 | |||
| 188 | void EmitUndefU1(EmitContext& ctx, IR::Inst& inst) { | 159 | void EmitUndefU1(EmitContext& ctx, IR::Inst& inst) { |
| 189 | ctx.AddU1("{}=false;", inst); | 160 | ctx.AddU1("{}=false;", inst); |
| 190 | } | 161 | } |