diff options
Diffstat (limited to 'src')
14 files changed, 71 insertions, 5 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index 7c11d15bf..07963a760 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt | |||
| @@ -137,6 +137,7 @@ add_library(shader_recompiler STATIC | |||
| 137 | frontend/maxwell/translate/impl/move_special_register.cpp | 137 | frontend/maxwell/translate/impl/move_special_register.cpp |
| 138 | frontend/maxwell/translate/impl/not_implemented.cpp | 138 | frontend/maxwell/translate/impl/not_implemented.cpp |
| 139 | frontend/maxwell/translate/impl/output_geometry.cpp | 139 | frontend/maxwell/translate/impl/output_geometry.cpp |
| 140 | frontend/maxwell/translate/impl/pixel_load.cpp | ||
| 140 | frontend/maxwell/translate/impl/predicate_set_predicate.cpp | 141 | frontend/maxwell/translate/impl/predicate_set_predicate.cpp |
| 141 | frontend/maxwell/translate/impl/predicate_set_register.cpp | 142 | frontend/maxwell/translate/impl/predicate_set_register.cpp |
| 142 | frontend/maxwell/translate/impl/select_source_with_predicate.cpp | 143 | frontend/maxwell/translate/impl/select_source_with_predicate.cpp |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 2f8678b4e..0b4abeb44 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -998,6 +998,9 @@ void EmitContext::DefineInputs(const Info& info) { | |||
| 998 | if (info.uses_invocation_id) { | 998 | if (info.uses_invocation_id) { |
| 999 | invocation_id = DefineInput(*this, U32[1], false, spv::BuiltIn::InvocationId); | 999 | invocation_id = DefineInput(*this, U32[1], false, spv::BuiltIn::InvocationId); |
| 1000 | } | 1000 | } |
| 1001 | if (info.uses_sample_id) { | ||
| 1002 | sample_id = DefineInput(*this, U32[1], false, spv::BuiltIn::SampleId); | ||
| 1003 | } | ||
| 1001 | if (info.uses_is_helper_invocation) { | 1004 | if (info.uses_is_helper_invocation) { |
| 1002 | is_helper_invocation = DefineInput(*this, U1, false, spv::BuiltIn::HelperInvocation); | 1005 | is_helper_invocation = DefineInput(*this, U1, false, spv::BuiltIn::HelperInvocation); |
| 1003 | } | 1006 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index c41cad098..9d8340333 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -149,6 +149,7 @@ public: | |||
| 149 | Id workgroup_id{}; | 149 | Id workgroup_id{}; |
| 150 | Id local_invocation_id{}; | 150 | Id local_invocation_id{}; |
| 151 | Id invocation_id{}; | 151 | Id invocation_id{}; |
| 152 | Id sample_id{}; | ||
| 152 | Id is_helper_invocation{}; | 153 | Id is_helper_invocation{}; |
| 153 | Id subgroup_local_invocation_id{}; | 154 | Id subgroup_local_invocation_id{}; |
| 154 | Id subgroup_mask_eq{}; | 155 | Id subgroup_mask_eq{}; |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 90c4833a8..9ec970706 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -335,6 +335,9 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct | |||
| 335 | if (info.uses_typeless_image_writes) { | 335 | if (info.uses_typeless_image_writes) { |
| 336 | ctx.AddCapability(spv::Capability::StorageImageWriteWithoutFormat); | 336 | ctx.AddCapability(spv::Capability::StorageImageWriteWithoutFormat); |
| 337 | } | 337 | } |
| 338 | if (info.uses_sample_id) { | ||
| 339 | ctx.AddCapability(spv::Capability::SampleRateShading); | ||
| 340 | } | ||
| 338 | if (!ctx.profile.xfb_varyings.empty()) { | 341 | if (!ctx.profile.xfb_varyings.empty()) { |
| 339 | ctx.AddCapability(spv::Capability::TransformFeedback); | 342 | ctx.AddCapability(spv::Capability::TransformFeedback); |
| 340 | } | 343 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.h b/src/shader_recompiler/backend/spirv/emit_spirv.h index 8caf30f1b..dfddf5e58 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv.h | |||
| @@ -70,6 +70,7 @@ void EmitSetOFlag(EmitContext& ctx); | |||
| 70 | Id EmitWorkgroupId(EmitContext& ctx); | 70 | Id EmitWorkgroupId(EmitContext& ctx); |
| 71 | Id EmitLocalInvocationId(EmitContext& ctx); | 71 | Id EmitLocalInvocationId(EmitContext& ctx); |
| 72 | Id EmitInvocationId(EmitContext& ctx); | 72 | Id EmitInvocationId(EmitContext& ctx); |
| 73 | Id EmitSampleId(EmitContext& ctx); | ||
| 73 | Id EmitIsHelperInvocation(EmitContext& ctx); | 74 | Id EmitIsHelperInvocation(EmitContext& ctx); |
| 74 | Id EmitLoadLocal(EmitContext& ctx, Id word_offset); | 75 | Id EmitLoadLocal(EmitContext& ctx, Id word_offset); |
| 75 | void EmitWriteLocal(EmitContext& ctx, Id word_offset, Id value); | 76 | void EmitWriteLocal(EmitContext& ctx, Id word_offset, Id value); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index aaa20ab95..7555dd94c 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | |||
| @@ -391,6 +391,10 @@ Id EmitInvocationId(EmitContext& ctx) { | |||
| 391 | return ctx.OpLoad(ctx.U32[1], ctx.invocation_id); | 391 | return ctx.OpLoad(ctx.U32[1], ctx.invocation_id); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | Id EmitSampleId(EmitContext& ctx) { | ||
| 395 | return ctx.OpLoad(ctx.U32[1], ctx.sample_id); | ||
| 396 | } | ||
| 397 | |||
| 394 | Id EmitIsHelperInvocation(EmitContext& ctx) { | 398 | Id EmitIsHelperInvocation(EmitContext& ctx) { |
| 395 | return ctx.OpLoad(ctx.U1, ctx.is_helper_invocation); | 399 | return ctx.OpLoad(ctx.U1, ctx.is_helper_invocation); |
| 396 | } | 400 | } |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index b821d9f47..141efd86c 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -375,6 +375,10 @@ U32 IREmitter::InvocationId() { | |||
| 375 | return Inst<U32>(Opcode::InvocationId); | 375 | return Inst<U32>(Opcode::InvocationId); |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | U32 IREmitter::SampleId() { | ||
| 379 | return Inst<U32>(Opcode::SampleId); | ||
| 380 | } | ||
| 381 | |||
| 378 | U1 IREmitter::IsHelperInvocation() { | 382 | U1 IREmitter::IsHelperInvocation() { |
| 379 | return Inst<U1>(Opcode::IsHelperInvocation); | 383 | return Inst<U1>(Opcode::IsHelperInvocation); |
| 380 | } | 384 | } |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 7f8f1ad42..81833d928 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -99,6 +99,7 @@ public: | |||
| 99 | [[nodiscard]] U32 LocalInvocationIdZ(); | 99 | [[nodiscard]] U32 LocalInvocationIdZ(); |
| 100 | 100 | ||
| 101 | [[nodiscard]] U32 InvocationId(); | 101 | [[nodiscard]] U32 InvocationId(); |
| 102 | [[nodiscard]] U32 SampleId(); | ||
| 102 | [[nodiscard]] U1 IsHelperInvocation(); | 103 | [[nodiscard]] U1 IsHelperInvocation(); |
| 103 | 104 | ||
| 104 | [[nodiscard]] U32 LaneId(); | 105 | [[nodiscard]] U32 LaneId(); |
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index a86542cd8..d5e443673 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -63,6 +63,7 @@ OPCODE(SetOFlag, Void, U1, | |||
| 63 | OPCODE(WorkgroupId, U32x3, ) | 63 | OPCODE(WorkgroupId, U32x3, ) |
| 64 | OPCODE(LocalInvocationId, U32x3, ) | 64 | OPCODE(LocalInvocationId, U32x3, ) |
| 65 | OPCODE(InvocationId, U32, ) | 65 | OPCODE(InvocationId, U32, ) |
| 66 | OPCODE(SampleId, U32, ) | ||
| 66 | OPCODE(IsHelperInvocation, U1, ) | 67 | OPCODE(IsHelperInvocation, U1, ) |
| 67 | 68 | ||
| 68 | // Undefined | 69 | // Undefined |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp index a45d1e4be..a4f99bbbe 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp | |||
| @@ -181,10 +181,6 @@ void TranslatorVisitor::PEXIT(u64) { | |||
| 181 | ThrowNotImplemented(Opcode::PEXIT); | 181 | ThrowNotImplemented(Opcode::PEXIT); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | void TranslatorVisitor::PIXLD(u64) { | ||
| 185 | ThrowNotImplemented(Opcode::PIXLD); | ||
| 186 | } | ||
| 187 | |||
| 188 | void TranslatorVisitor::PLONGJMP(u64) { | 184 | void TranslatorVisitor::PLONGJMP(u64) { |
| 189 | ThrowNotImplemented(Opcode::PLONGJMP); | 185 | ThrowNotImplemented(Opcode::PLONGJMP); |
| 190 | } | 186 | } |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp new file mode 100644 index 000000000..b4767afb5 --- /dev/null +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/pixel_load.cpp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/bit_field.h" | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "shader_recompiler/frontend/maxwell/translate/impl/impl.h" | ||
| 8 | |||
| 9 | namespace Shader::Maxwell { | ||
| 10 | namespace { | ||
| 11 | enum class Mode : u64 { | ||
| 12 | Default, | ||
| 13 | CovMask, | ||
| 14 | Covered, | ||
| 15 | Offset, | ||
| 16 | CentroidOffset, | ||
| 17 | MyIndex, | ||
| 18 | }; | ||
| 19 | } // Anonymous namespace | ||
| 20 | |||
| 21 | void TranslatorVisitor::PIXLD(u64 insn) { | ||
| 22 | union { | ||
| 23 | u64 raw; | ||
| 24 | BitField<31, 3, Mode> mode; | ||
| 25 | BitField<0, 8, IR::Reg> dest_reg; | ||
| 26 | BitField<8, 8, IR::Reg> addr_reg; | ||
| 27 | BitField<20, 8, s64> addr_offset; | ||
| 28 | BitField<45, 3, IR::Pred> dest_pred; | ||
| 29 | } const pixld{insn}; | ||
| 30 | |||
| 31 | if (pixld.dest_pred != IR::Pred::PT) { | ||
| 32 | throw NotImplementedException("Destination predicate"); | ||
| 33 | } | ||
| 34 | if (pixld.addr_reg != IR::Reg::RZ || pixld.addr_offset != 0) { | ||
| 35 | throw NotImplementedException("Non-zero source register"); | ||
| 36 | } | ||
| 37 | switch (pixld.mode) { | ||
| 38 | case Mode::MyIndex: | ||
| 39 | X(pixld.dest_reg, ir.SampleId()); | ||
| 40 | break; | ||
| 41 | default: | ||
| 42 | throw NotImplementedException("Mode {}", pixld.mode.Value()); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | } // namespace Shader::Maxwell | ||
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp index 9631a445e..5d1310466 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -415,6 +415,9 @@ void VisitUsages(Info& info, IR::Inst& inst) { | |||
| 415 | case IR::Opcode::InvocationId: | 415 | case IR::Opcode::InvocationId: |
| 416 | info.uses_invocation_id = true; | 416 | info.uses_invocation_id = true; |
| 417 | break; | 417 | break; |
| 418 | case IR::Opcode::SampleId: | ||
| 419 | info.uses_sample_id = true; | ||
| 420 | break; | ||
| 418 | case IR::Opcode::IsHelperInvocation: | 421 | case IR::Opcode::IsHelperInvocation: |
| 419 | info.uses_is_helper_invocation = true; | 422 | info.uses_is_helper_invocation = true; |
| 420 | break; | 423 | break; |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index d33df8aad..686f5c719 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -102,6 +102,7 @@ struct Info { | |||
| 102 | bool uses_workgroup_id{}; | 102 | bool uses_workgroup_id{}; |
| 103 | bool uses_local_invocation_id{}; | 103 | bool uses_local_invocation_id{}; |
| 104 | bool uses_invocation_id{}; | 104 | bool uses_invocation_id{}; |
| 105 | bool uses_sample_id{}; | ||
| 105 | bool uses_is_helper_invocation{}; | 106 | bool uses_is_helper_invocation{}; |
| 106 | bool uses_subgroup_invocation_id{}; | 107 | bool uses_subgroup_invocation_id{}; |
| 107 | std::array<bool, 30> uses_patches{}; | 108 | std::array<bool, 30> uses_patches{}; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 72b83f99a..038231298 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -218,7 +218,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 218 | .independentBlend = true, | 218 | .independentBlend = true, |
| 219 | .geometryShader = true, | 219 | .geometryShader = true, |
| 220 | .tessellationShader = true, | 220 | .tessellationShader = true, |
| 221 | .sampleRateShading = false, | 221 | .sampleRateShading = true, |
| 222 | .dualSrcBlend = false, | 222 | .dualSrcBlend = false, |
| 223 | .logicOp = false, | 223 | .logicOp = false, |
| 224 | .multiDrawIndirect = false, | 224 | .multiDrawIndirect = false, |
| @@ -677,6 +677,7 @@ void Device::CheckSuitability(bool requires_swapchain) const { | |||
| 677 | std::make_pair(features.fillModeNonSolid, "fillModeNonSolid"), | 677 | std::make_pair(features.fillModeNonSolid, "fillModeNonSolid"), |
| 678 | std::make_pair(features.geometryShader, "geometryShader"), | 678 | std::make_pair(features.geometryShader, "geometryShader"), |
| 679 | std::make_pair(features.tessellationShader, "tessellationShader"), | 679 | std::make_pair(features.tessellationShader, "tessellationShader"), |
| 680 | std::make_pair(features.sampleRateShading, "sampleRateShading"), | ||
| 680 | std::make_pair(features.occlusionQueryPrecise, "occlusionQueryPrecise"), | 681 | std::make_pair(features.occlusionQueryPrecise, "occlusionQueryPrecise"), |
| 681 | std::make_pair(features.fragmentStoresAndAtomics, "fragmentStoresAndAtomics"), | 682 | std::make_pair(features.fragmentStoresAndAtomics, "fragmentStoresAndAtomics"), |
| 682 | std::make_pair(features.shaderImageGatherExtended, "shaderImageGatherExtended"), | 683 | std::make_pair(features.shaderImageGatherExtended, "shaderImageGatherExtended"), |