diff options
| author | 2021-11-16 18:52:11 -0800 | |
|---|---|---|
| committer | 2021-11-16 18:52:11 -0800 | |
| commit | 71313509f75aeafe425e531824d1faa9e7c0a40b (patch) | |
| tree | cb1df371d288677fcede6a3409eb079e0d278163 /src/shader_recompiler/backend/glsl | |
| parent | Merge pull request #7347 from lioncash/catch (diff) | |
| parent | TextureCache: Fix Automatic Anisotropic. (diff) | |
| download | yuzu-71313509f75aeafe425e531824d1faa9e7c0a40b.tar.gz yuzu-71313509f75aeafe425e531824d1faa9e7c0a40b.tar.xz yuzu-71313509f75aeafe425e531824d1faa9e7c0a40b.zip | |
Merge pull request #7219 from FernandoS27/aristotles-right-testicle
Project A.R.T. Advanced Rendering Techniques
Diffstat (limited to 'src/shader_recompiler/backend/glsl')
5 files changed, 36 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index 4e6f2c0fe..97bd59302 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -393,6 +393,9 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 393 | DefineGenericOutput(index, program.invocations); | 393 | DefineGenericOutput(index, program.invocations); |
| 394 | } | 394 | } |
| 395 | } | 395 | } |
| 396 | if (info.uses_rescaling_uniform) { | ||
| 397 | header += "layout(location=0) uniform vec4 scaling;"; | ||
| 398 | } | ||
| 396 | DefineConstantBuffers(bindings); | 399 | DefineConstantBuffers(bindings); |
| 397 | DefineStorageBuffers(bindings); | 400 | DefineStorageBuffers(bindings); |
| 398 | SetupImages(bindings); | 401 | SetupImages(bindings); |
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 170db269a..4c26f3829 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 | |||
| @@ -445,6 +445,10 @@ void EmitYDirection(EmitContext& ctx, IR::Inst& inst) { | |||
| 445 | ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst); | 445 | ctx.AddF32("{}=gl_FrontMaterial.ambient.a;", inst); |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | void EmitResolutionDownFactor(EmitContext& ctx, IR::Inst& inst) { | ||
| 449 | ctx.AddF32("{}=scaling.z;", inst); | ||
| 450 | } | ||
| 451 | |||
| 448 | void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset) { | 452 | void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset) { |
| 449 | ctx.AddU32("{}=lmem[{}];", inst, word_offset); | 453 | ctx.AddU32("{}=lmem[{}];", inst, word_offset); |
| 450 | } | 454 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index 447eb8e0a..2f78d0267 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -612,6 +612,22 @@ void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value | |||
| 612 | value); | 612 | value); |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | void EmitIsTextureScaled(EmitContext& ctx, IR::Inst& inst, const IR::Value& index) { | ||
| 616 | if (!index.IsImmediate()) { | ||
| 617 | throw NotImplementedException("Non-constant texture rescaling"); | ||
| 618 | } | ||
| 619 | const u32 image_index{index.U32()}; | ||
| 620 | ctx.AddU1("{}=(ftou(scaling.x)&{})!=0;", inst, 1u << image_index); | ||
| 621 | } | ||
| 622 | |||
| 623 | void EmitIsImageScaled(EmitContext& ctx, IR::Inst& inst, const IR::Value& index) { | ||
| 624 | if (!index.IsImmediate()) { | ||
| 625 | throw NotImplementedException("Non-constant texture rescaling"); | ||
| 626 | } | ||
| 627 | const u32 image_index{index.U32()}; | ||
| 628 | ctx.AddU1("{}=(ftou(scaling.y)&{})!=0;", inst, 1u << image_index); | ||
| 629 | } | ||
| 630 | |||
| 615 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | 631 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { |
| 616 | NotImplemented(); | 632 | NotImplemented(); |
| 617 | } | 633 | } |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index 5936d086f..f86502e4c 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | |||
| @@ -85,6 +85,7 @@ void EmitInvocationId(EmitContext& ctx, IR::Inst& inst); | |||
| 85 | void EmitSampleId(EmitContext& ctx, IR::Inst& inst); | 85 | void EmitSampleId(EmitContext& ctx, IR::Inst& inst); |
| 86 | void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst); | 86 | void EmitIsHelperInvocation(EmitContext& ctx, IR::Inst& inst); |
| 87 | void EmitYDirection(EmitContext& ctx, IR::Inst& inst); | 87 | void EmitYDirection(EmitContext& ctx, IR::Inst& inst); |
| 88 | void EmitResolutionDownFactor(EmitContext& ctx, IR::Inst& inst); | ||
| 88 | void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset); | 89 | void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, std::string_view word_offset); |
| 89 | void EmitWriteLocal(EmitContext& ctx, std::string_view word_offset, std::string_view value); | 90 | void EmitWriteLocal(EmitContext& ctx, std::string_view word_offset, std::string_view value); |
| 90 | void EmitUndefU1(EmitContext& ctx, IR::Inst& inst); | 91 | void EmitUndefU1(EmitContext& ctx, IR::Inst& inst); |
| @@ -362,6 +363,8 @@ void EmitIAdd64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 362 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | 363 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 363 | void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | 364 | void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 364 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | 365 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 366 | void EmitSDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | ||
| 367 | void EmitUDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | ||
| 365 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 368 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 366 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 369 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 367 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 370 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| @@ -627,6 +630,8 @@ void EmitImageRead(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | |||
| 627 | std::string_view coords); | 630 | std::string_view coords); |
| 628 | void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | 631 | void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, |
| 629 | std::string_view coords, std::string_view color); | 632 | std::string_view coords, std::string_view color); |
| 633 | void EmitIsTextureScaled(EmitContext& ctx, IR::Inst& inst, const IR::Value& index); | ||
| 634 | void EmitIsImageScaled(EmitContext& ctx, IR::Inst& inst, const IR::Value& index); | ||
| 630 | void EmitBindlessImageAtomicIAdd32(EmitContext&); | 635 | void EmitBindlessImageAtomicIAdd32(EmitContext&); |
| 631 | void EmitBindlessImageAtomicSMin32(EmitContext&); | 636 | void EmitBindlessImageAtomicSMin32(EmitContext&); |
| 632 | void EmitBindlessImageAtomicUMin32(EmitContext&); | 637 | void EmitBindlessImageAtomicUMin32(EmitContext&); |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp index 38419f88f..88c1d4c5e 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp | |||
| @@ -78,6 +78,14 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 78 | ctx.AddU32("{}=uint({}*{});", inst, a, b); | 78 | ctx.AddU32("{}=uint({}*{});", inst, a, b); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | void EmitSDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 82 | ctx.AddU32("{}=uint(int({})/int({}));", inst, a, b); | ||
| 83 | } | ||
| 84 | |||
| 85 | void EmitUDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 86 | ctx.AddU32("{}={}/{};", inst, a, b); | ||
| 87 | } | ||
| 88 | |||
| 81 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | 89 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { |
| 82 | ctx.AddU32("{}=uint(-({}));", inst, value); | 90 | ctx.AddU32("{}=uint(-({}));", inst, value); |
| 83 | } | 91 | } |