mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-12-23 22:43:04 +00:00
shader: Implement PIXLD.MY_INDEX
This commit is contained in:
parent
f3473c5143
commit
95815a3883
14 changed files with 71 additions and 5 deletions
|
@ -137,6 +137,7 @@ add_library(shader_recompiler STATIC
|
|||
frontend/maxwell/translate/impl/move_special_register.cpp
|
||||
frontend/maxwell/translate/impl/not_implemented.cpp
|
||||
frontend/maxwell/translate/impl/output_geometry.cpp
|
||||
frontend/maxwell/translate/impl/pixel_load.cpp
|
||||
frontend/maxwell/translate/impl/predicate_set_predicate.cpp
|
||||
frontend/maxwell/translate/impl/predicate_set_register.cpp
|
||||
frontend/maxwell/translate/impl/select_source_with_predicate.cpp
|
||||
|
|
|
@ -998,6 +998,9 @@ void EmitContext::DefineInputs(const Info& info) {
|
|||
if (info.uses_invocation_id) {
|
||||
invocation_id = DefineInput(*this, U32[1], false, spv::BuiltIn::InvocationId);
|
||||
}
|
||||
if (info.uses_sample_id) {
|
||||
sample_id = DefineInput(*this, U32[1], false, spv::BuiltIn::SampleId);
|
||||
}
|
||||
if (info.uses_is_helper_invocation) {
|
||||
is_helper_invocation = DefineInput(*this, U1, false, spv::BuiltIn::HelperInvocation);
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@ public:
|
|||
Id workgroup_id{};
|
||||
Id local_invocation_id{};
|
||||
Id invocation_id{};
|
||||
Id sample_id{};
|
||||
Id is_helper_invocation{};
|
||||
Id subgroup_local_invocation_id{};
|
||||
Id subgroup_mask_eq{};
|
||||
|
|
|
@ -335,6 +335,9 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
|
|||
if (info.uses_typeless_image_writes) {
|
||||
ctx.AddCapability(spv::Capability::StorageImageWriteWithoutFormat);
|
||||
}
|
||||
if (info.uses_sample_id) {
|
||||
ctx.AddCapability(spv::Capability::SampleRateShading);
|
||||
}
|
||||
if (!ctx.profile.xfb_varyings.empty()) {
|
||||
ctx.AddCapability(spv::Capability::TransformFeedback);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ void EmitSetOFlag(EmitContext& ctx);
|
|||
Id EmitWorkgroupId(EmitContext& ctx);
|
||||
Id EmitLocalInvocationId(EmitContext& ctx);
|
||||
Id EmitInvocationId(EmitContext& ctx);
|
||||
Id EmitSampleId(EmitContext& ctx);
|
||||
Id EmitIsHelperInvocation(EmitContext& ctx);
|
||||
Id EmitLoadLocal(EmitContext& ctx, Id word_offset);
|
||||
void EmitWriteLocal(EmitContext& ctx, Id word_offset, Id value);
|
||||
|
|
|
@ -391,6 +391,10 @@ Id EmitInvocationId(EmitContext& ctx) {
|
|||
return ctx.OpLoad(ctx.U32[1], ctx.invocation_id);
|
||||
}
|
||||
|
||||
Id EmitSampleId(EmitContext& ctx) {
|
||||
return ctx.OpLoad(ctx.U32[1], ctx.sample_id);
|
||||
}
|
||||
|
||||
Id EmitIsHelperInvocation(EmitContext& ctx) {
|
||||
return ctx.OpLoad(ctx.U1, ctx.is_helper_invocation);
|
||||
}
|
||||
|
|
|
@ -375,6 +375,10 @@ U32 IREmitter::InvocationId() {
|
|||
return Inst<U32>(Opcode::InvocationId);
|
||||
}
|
||||
|
||||
U32 IREmitter::SampleId() {
|
||||
return Inst<U32>(Opcode::SampleId);
|
||||
}
|
||||
|
||||
U1 IREmitter::IsHelperInvocation() {
|
||||
return Inst<U1>(Opcode::IsHelperInvocation);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
[[nodiscard]] U32 LocalInvocationIdZ();
|
||||
|
||||
[[nodiscard]] U32 InvocationId();
|
||||
[[nodiscard]] U32 SampleId();
|
||||
[[nodiscard]] U1 IsHelperInvocation();
|
||||
|
||||
[[nodiscard]] U32 LaneId();
|
||||
|
|
|
@ -63,6 +63,7 @@ OPCODE(SetOFlag, Void, U1,
|
|||
OPCODE(WorkgroupId, U32x3, )
|
||||
OPCODE(LocalInvocationId, U32x3, )
|
||||
OPCODE(InvocationId, U32, )
|
||||
OPCODE(SampleId, U32, )
|
||||
OPCODE(IsHelperInvocation, U1, )
|
||||
|
||||
// Undefined
|
||||
|
|
|
@ -181,10 +181,6 @@ void TranslatorVisitor::PEXIT(u64) {
|
|||
ThrowNotImplemented(Opcode::PEXIT);
|
||||
}
|
||||
|
||||
void TranslatorVisitor::PIXLD(u64) {
|
||||
ThrowNotImplemented(Opcode::PIXLD);
|
||||
}
|
||||
|
||||
void TranslatorVisitor::PLONGJMP(u64) {
|
||||
ThrowNotImplemented(Opcode::PLONGJMP);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2021 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
|
||||
|
||||
namespace Shader::Maxwell {
|
||||
namespace {
|
||||
enum class Mode : u64 {
|
||||
Default,
|
||||
CovMask,
|
||||
Covered,
|
||||
Offset,
|
||||
CentroidOffset,
|
||||
MyIndex,
|
||||
};
|
||||
} // Anonymous namespace
|
||||
|
||||
void TranslatorVisitor::PIXLD(u64 insn) {
|
||||
union {
|
||||
u64 raw;
|
||||
BitField<31, 3, Mode> mode;
|
||||
BitField<0, 8, IR::Reg> dest_reg;
|
||||
BitField<8, 8, IR::Reg> addr_reg;
|
||||
BitField<20, 8, s64> addr_offset;
|
||||
BitField<45, 3, IR::Pred> dest_pred;
|
||||
} const pixld{insn};
|
||||
|
||||
if (pixld.dest_pred != IR::Pred::PT) {
|
||||
throw NotImplementedException("Destination predicate");
|
||||
}
|
||||
if (pixld.addr_reg != IR::Reg::RZ || pixld.addr_offset != 0) {
|
||||
throw NotImplementedException("Non-zero source register");
|
||||
}
|
||||
switch (pixld.mode) {
|
||||
case Mode::MyIndex:
|
||||
X(pixld.dest_reg, ir.SampleId());
|
||||
break;
|
||||
default:
|
||||
throw NotImplementedException("Mode {}", pixld.mode.Value());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Shader::Maxwell
|
|
@ -415,6 +415,9 @@ void VisitUsages(Info& info, IR::Inst& inst) {
|
|||
case IR::Opcode::InvocationId:
|
||||
info.uses_invocation_id = true;
|
||||
break;
|
||||
case IR::Opcode::SampleId:
|
||||
info.uses_sample_id = true;
|
||||
break;
|
||||
case IR::Opcode::IsHelperInvocation:
|
||||
info.uses_is_helper_invocation = true;
|
||||
break;
|
||||
|
|
|
@ -102,6 +102,7 @@ struct Info {
|
|||
bool uses_workgroup_id{};
|
||||
bool uses_local_invocation_id{};
|
||||
bool uses_invocation_id{};
|
||||
bool uses_sample_id{};
|
||||
bool uses_is_helper_invocation{};
|
||||
bool uses_subgroup_invocation_id{};
|
||||
std::array<bool, 30> uses_patches{};
|
||||
|
|
|
@ -218,7 +218,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
|||
.independentBlend = true,
|
||||
.geometryShader = true,
|
||||
.tessellationShader = true,
|
||||
.sampleRateShading = false,
|
||||
.sampleRateShading = true,
|
||||
.dualSrcBlend = false,
|
||||
.logicOp = false,
|
||||
.multiDrawIndirect = false,
|
||||
|
@ -677,6 +677,7 @@ void Device::CheckSuitability(bool requires_swapchain) const {
|
|||
std::make_pair(features.fillModeNonSolid, "fillModeNonSolid"),
|
||||
std::make_pair(features.geometryShader, "geometryShader"),
|
||||
std::make_pair(features.tessellationShader, "tessellationShader"),
|
||||
std::make_pair(features.sampleRateShading, "sampleRateShading"),
|
||||
std::make_pair(features.occlusionQueryPrecise, "occlusionQueryPrecise"),
|
||||
std::make_pair(features.fragmentStoresAndAtomics, "fragmentStoresAndAtomics"),
|
||||
std::make_pair(features.shaderImageGatherExtended, "shaderImageGatherExtended"),
|
||||
|
|
Loading…
Reference in a new issue