Browse Source

[spir-v] Flat decorations for input interfaces

pull/3169/head
CamilleLaVey 4 weeks ago
committed by Caio Oliveira
parent
commit
df8ed3607d
No known key found for this signature in database GPG Key ID: 362DA3DC1901E080
  1. 21
      src/shader_recompiler/backend/spirv/spirv_emit_context.cpp

21
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp

@ -1435,6 +1435,9 @@ void EmitContext::DefineInputs(const IR::Program& program) {
} }
if (info.uses_sample_id) { if (info.uses_sample_id) {
sample_id = DefineInput(*this, U32[1], false, spv::BuiltIn::SampleId); sample_id = DefineInput(*this, U32[1], false, spv::BuiltIn::SampleId);
if (stage == Stage::Fragment) {
Decorate(sample_id, spv::Decoration::Flat);
}
} }
if (info.uses_is_helper_invocation) { if (info.uses_is_helper_invocation) {
is_helper_invocation = DefineInput(*this, U1, false, spv::BuiltIn::HelperInvocation); is_helper_invocation = DefineInput(*this, U1, false, spv::BuiltIn::HelperInvocation);
@ -1445,6 +1448,13 @@ void EmitContext::DefineInputs(const IR::Program& program) {
subgroup_mask_le = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupLeMaskKHR); subgroup_mask_le = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupLeMaskKHR);
subgroup_mask_gt = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupGtMaskKHR); subgroup_mask_gt = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupGtMaskKHR);
subgroup_mask_ge = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupGeMaskKHR); subgroup_mask_ge = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupGeMaskKHR);
if (stage == Stage::Fragment) {
Decorate(subgroup_mask_eq, spv::Decoration::Flat);
Decorate(subgroup_mask_lt, spv::Decoration::Flat);
Decorate(subgroup_mask_le, spv::Decoration::Flat);
Decorate(subgroup_mask_gt, spv::Decoration::Flat);
Decorate(subgroup_mask_ge, spv::Decoration::Flat);
}
} }
if (info.uses_fswzadd || info.uses_subgroup_invocation_id || info.uses_subgroup_shuffles || if (info.uses_fswzadd || info.uses_subgroup_invocation_id || info.uses_subgroup_shuffles ||
(profile.warp_size_potentially_larger_than_guest && (profile.warp_size_potentially_larger_than_guest &&
@ -1464,6 +1474,9 @@ void EmitContext::DefineInputs(const IR::Program& program) {
} }
if (loads[IR::Attribute::PrimitiveId]) { if (loads[IR::Attribute::PrimitiveId]) {
primitive_id = DefineInput(*this, U32[1], false, spv::BuiltIn::PrimitiveId); primitive_id = DefineInput(*this, U32[1], false, spv::BuiltIn::PrimitiveId);
if (stage == Stage::Fragment) {
Decorate(primitive_id, spv::Decoration::Flat);
}
} }
if (loads[IR::Attribute::Layer]) { if (loads[IR::Attribute::Layer]) {
AddCapability(spv::Capability::Geometry); AddCapability(spv::Capability::Geometry);
@ -1555,10 +1568,13 @@ void EmitContext::DefineInputs(const IR::Program& program) {
if (stage != Stage::Fragment) { if (stage != Stage::Fragment) {
continue; continue;
} }
const bool is_integer = input_type == AttributeType::SignedInt ||
input_type == AttributeType::UnsignedInt;
if (is_integer) {
Decorate(id, spv::Decoration::Flat);
} else {
switch (info.interpolation[index]) { switch (info.interpolation[index]) {
case Interpolation::Smooth: case Interpolation::Smooth:
// Default
// Decorate(id, spv::Decoration::Smooth);
break; break;
case Interpolation::NoPerspective: case Interpolation::NoPerspective:
Decorate(id, spv::Decoration::NoPerspective); Decorate(id, spv::Decoration::NoPerspective);
@ -1568,6 +1584,7 @@ void EmitContext::DefineInputs(const IR::Program& program) {
break; break;
} }
} }
}
if (stage == Stage::TessellationEval) { if (stage == Stage::TessellationEval) {
for (size_t index = 0; index < info.uses_patches.size(); ++index) { for (size_t index = 0; index < info.uses_patches.size(); ++index) {
if (!info.uses_patches[index]) { if (!info.uses_patches[index]) {

Loading…
Cancel
Save