shader: Address Feedback
This commit is contained in:
parent
45d547af11
commit
baec84247f
16 changed files with 60 additions and 211 deletions
|
@ -510,7 +510,8 @@ void EmitContext::DefineOutputs(const Info& info) {
|
|||
const Id type{TypeArray(F32[1], Constant(U32[1], 8U))};
|
||||
clip_distances = DefineOutput(*this, type, spv::BuiltIn::ClipDistance);
|
||||
}
|
||||
if (info.stores_viewport_index && !ignore_viewport_layer) {
|
||||
if (info.stores_viewport_index &&
|
||||
(profile.support_viewport_index_layer_non_geometry || stage == Shader::Stage::Geometry)) {
|
||||
if (stage == Stage::Fragment) {
|
||||
throw NotImplementedException("Storing ViewportIndex in Fragment stage");
|
||||
}
|
||||
|
|
|
@ -134,8 +134,6 @@ public:
|
|||
|
||||
std::vector<Id> interfaces;
|
||||
|
||||
bool ignore_viewport_layer{};
|
||||
|
||||
private:
|
||||
void DefineCommonTypes(const Info& info);
|
||||
void DefineCommonConstants();
|
||||
|
|
|
@ -228,11 +228,9 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
|
|||
if (info.stores_viewport_index) {
|
||||
ctx.AddCapability(spv::Capability::MultiViewport);
|
||||
if (profile.support_viewport_index_layer_non_geometry &&
|
||||
ctx.stage == Shader::Stage::VertexB) {
|
||||
ctx.stage != Shader::Stage::Geometry) {
|
||||
ctx.AddExtension("SPV_EXT_shader_viewport_index_layer");
|
||||
ctx.AddCapability(spv::Capability::ShaderViewportIndexLayerEXT);
|
||||
} else {
|
||||
ctx.ignore_viewport_layer = true;
|
||||
}
|
||||
}
|
||||
if (!profile.support_vertex_instance_id && (info.loads_instance_id || info.loads_vertex_id)) {
|
||||
|
|
|
@ -28,7 +28,9 @@ void EmitSelectionMerge(EmitContext& ctx, Id merge_label);
|
|||
void EmitReturn(EmitContext& ctx);
|
||||
void EmitUnreachable(EmitContext& ctx);
|
||||
void EmitDemoteToHelperInvocation(EmitContext& ctx, Id continue_label);
|
||||
void EmitMemoryBarrier(EmitContext& ctx, IR::Inst* inst);
|
||||
void EmitMemoryBarrierWorkgroupLevel(EmitContext& ctx);
|
||||
void EmitMemoryBarrierDeviceLevel(EmitContext& ctx);
|
||||
void EmitMemoryBarrierSystemLevel(EmitContext& ctx);
|
||||
void EmitPrologue(EmitContext& ctx);
|
||||
void EmitEpilogue(EmitContext& ctx);
|
||||
void EmitGetRegister(EmitContext& ctx);
|
||||
|
@ -60,14 +62,6 @@ void EmitSetZFlag(EmitContext& ctx);
|
|||
void EmitSetSFlag(EmitContext& ctx);
|
||||
void EmitSetCFlag(EmitContext& ctx);
|
||||
void EmitSetOFlag(EmitContext& ctx);
|
||||
void EmitGetFCSMFlag(EmitContext& ctx);
|
||||
void EmitGetTAFlag(EmitContext& ctx);
|
||||
void EmitGetTRFlag(EmitContext& ctx);
|
||||
void EmitGetMXFlag(EmitContext& ctx);
|
||||
void EmitSetFCSMFlag(EmitContext& ctx);
|
||||
void EmitSetTAFlag(EmitContext& ctx);
|
||||
void EmitSetTRFlag(EmitContext& ctx);
|
||||
void EmitSetMXFlag(EmitContext& ctx);
|
||||
Id EmitWorkgroupId(EmitContext& ctx);
|
||||
Id EmitLocalInvocationId(EmitContext& ctx);
|
||||
Id EmitLoadLocal(EmitContext& ctx, Id word_offset);
|
||||
|
|
|
@ -7,34 +7,27 @@
|
|||
|
||||
namespace Shader::Backend::SPIRV {
|
||||
namespace {
|
||||
spv::Scope MemoryScopeToSpirVScope(IR::MemoryScope scope) {
|
||||
switch (scope) {
|
||||
case IR::MemoryScope::Warp:
|
||||
return spv::Scope::Subgroup;
|
||||
case IR::MemoryScope::Workgroup:
|
||||
return spv::Scope::Workgroup;
|
||||
case IR::MemoryScope::Device:
|
||||
return spv::Scope::Device;
|
||||
case IR::MemoryScope::System:
|
||||
return spv::Scope::CrossDevice;
|
||||
case IR::MemoryScope::DontCare:
|
||||
return spv::Scope::Invocation;
|
||||
default:
|
||||
throw NotImplementedException("Unknown memory scope!");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void EmitMemoryBarrier(EmitContext& ctx, IR::Inst* inst) {
|
||||
const auto info{inst->Flags<IR::BarrierInstInfo>()};
|
||||
void EmitMemoryBarrierImpl(EmitContext& ctx, spv::Scope scope) {
|
||||
const auto semantics =
|
||||
spv::MemorySemanticsMask::AcquireRelease | spv::MemorySemanticsMask::UniformMemory |
|
||||
spv::MemorySemanticsMask::WorkgroupMemory | spv::MemorySemanticsMask::AtomicCounterMemory |
|
||||
spv::MemorySemanticsMask::ImageMemory;
|
||||
const auto scope = MemoryScopeToSpirVScope(info.scope);
|
||||
ctx.OpMemoryBarrier(ctx.Constant(ctx.U32[1], static_cast<u32>(scope)),
|
||||
ctx.Constant(ctx.U32[1], static_cast<u32>(semantics)));
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
void EmitMemoryBarrierWorkgroupLevel(EmitContext& ctx) {
|
||||
EmitMemoryBarrierImpl(ctx, spv::Scope::Workgroup);
|
||||
}
|
||||
|
||||
void EmitMemoryBarrierDeviceLevel(EmitContext& ctx) {
|
||||
EmitMemoryBarrierImpl(ctx, spv::Scope::Device);
|
||||
}
|
||||
|
||||
void EmitMemoryBarrierSystemLevel(EmitContext& ctx) {
|
||||
EmitMemoryBarrierImpl(ctx, spv::Scope::CrossDevice);
|
||||
}
|
||||
|
||||
} // namespace Shader::Backend::SPIRV
|
||||
|
|
|
@ -58,7 +58,10 @@ std::optional<Id> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) {
|
|||
return ctx.OpAccessChain(ctx.output_f32, ctx.clip_distances, clip_num);
|
||||
}
|
||||
case IR::Attribute::ViewportIndex:
|
||||
return ctx.ignore_viewport_layer ? std::nullopt : std::optional<Id>{ctx.viewport_index};
|
||||
return (ctx.profile.support_viewport_index_layer_non_geometry ||
|
||||
ctx.stage == Shader::Stage::Geometry)
|
||||
? std::optional<Id>{ctx.viewport_index}
|
||||
: std::nullopt;
|
||||
default:
|
||||
throw NotImplementedException("Read attribute {}", attr);
|
||||
}
|
||||
|
@ -206,7 +209,7 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr) {
|
|||
}
|
||||
|
||||
void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, Id value) {
|
||||
auto output = OutputAttrPointer(ctx, attr);
|
||||
const std::optional<Id> output{OutputAttrPointer(ctx, attr)};
|
||||
if (!output) {
|
||||
return;
|
||||
}
|
||||
|
@ -263,38 +266,6 @@ void EmitSetOFlag(EmitContext&) {
|
|||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitGetFCSMFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitGetTAFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitGetTRFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitGetMXFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitSetFCSMFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitSetTAFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitSetTRFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
void EmitSetMXFlag(EmitContext&) {
|
||||
throw NotImplementedException("SPIR-V Instruction");
|
||||
}
|
||||
|
||||
Id EmitWorkgroupId(EmitContext& ctx) {
|
||||
return ctx.OpLoad(ctx.U32[3], ctx.workgroup_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue