spirv: Implement ViewportMask with NV_viewport_array2
This commit is contained in:
parent
4657cf78fd
commit
e3514bcd6b
10 changed files with 32 additions and 0 deletions
|
@ -457,6 +457,7 @@ void EmitContext::DefineCommonTypes(const Info& info) {
|
|||
input_s32 = Name(TypePointer(spv::StorageClass::Input, TypeInt(32, true)), "input_s32");
|
||||
|
||||
output_f32 = Name(TypePointer(spv::StorageClass::Output, F32[1]), "output_f32");
|
||||
output_u32 = Name(TypePointer(spv::StorageClass::Output, U32[1]), "output_u32");
|
||||
|
||||
if (info.uses_int8) {
|
||||
AddCapability(spv::Capability::Int8);
|
||||
|
@ -1131,6 +1132,9 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
|
|||
}
|
||||
viewport_index = DefineOutput(*this, U32[1], invocations, spv::BuiltIn::ViewportIndex);
|
||||
}
|
||||
if (info.stores_viewport_mask && profile.support_viewport_mask) {
|
||||
viewport_mask = DefineOutput(*this, TypeArray(U32[1], Constant(U32[1], 1u)), std::nullopt);
|
||||
}
|
||||
for (size_t index = 0; index < info.stores_generics.size(); ++index) {
|
||||
if (info.stores_generics[index]) {
|
||||
DefineGenericOutput(*this, index, invocations);
|
||||
|
|
|
@ -134,6 +134,7 @@ public:
|
|||
Id input_s32{};
|
||||
|
||||
Id output_f32{};
|
||||
Id output_u32{};
|
||||
|
||||
Id image_buffer_type{};
|
||||
Id sampled_texture_buffer_type{};
|
||||
|
@ -167,6 +168,7 @@ public:
|
|||
Id clip_distances{};
|
||||
Id layer{};
|
||||
Id viewport_index{};
|
||||
Id viewport_mask{};
|
||||
Id primitive_id{};
|
||||
|
||||
Id fswzadd_lut_a{};
|
||||
|
|
|
@ -303,6 +303,10 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
|
|||
if (info.stores_viewport_index) {
|
||||
ctx.AddCapability(spv::Capability::MultiViewport);
|
||||
}
|
||||
if (info.stores_viewport_mask && profile.support_viewport_mask) {
|
||||
ctx.AddExtension("SPV_NV_viewport_array2");
|
||||
ctx.AddCapability(spv::Capability::ShaderViewportMaskNV);
|
||||
}
|
||||
if (info.stores_layer || info.stores_viewport_index) {
|
||||
if (profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) {
|
||||
ctx.AddExtension("SPV_EXT_shader_viewport_index_layer");
|
||||
|
|
|
@ -99,6 +99,11 @@ std::optional<Id> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) {
|
|||
ctx.stage == Shader::Stage::Geometry
|
||||
? std::optional<Id>{ctx.viewport_index}
|
||||
: std::nullopt;
|
||||
case IR::Attribute::ViewportMask:
|
||||
if (!ctx.profile.support_viewport_mask) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return ctx.OpAccessChain(ctx.output_u32, ctx.viewport_mask, ctx.u32_zero_value);
|
||||
default:
|
||||
throw NotImplementedException("Read attribute {}", attr);
|
||||
}
|
||||
|
|
|
@ -96,6 +96,9 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
|
|||
case IR::Attribute::ViewportIndex:
|
||||
info.stores_viewport_index = true;
|
||||
break;
|
||||
case IR::Attribute::ViewportMask:
|
||||
info.stores_viewport_mask = true;
|
||||
break;
|
||||
default:
|
||||
throw NotImplementedException("Set attribute {}", attribute);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ struct Profile {
|
|||
bool support_explicit_workgroup_layout{};
|
||||
bool support_vote{};
|
||||
bool support_viewport_index_layer_non_geometry{};
|
||||
bool support_viewport_mask{};
|
||||
bool support_typeless_image_loads{};
|
||||
bool warp_size_potentially_larger_than_guest{};
|
||||
bool support_int64_atomics{};
|
||||
|
|
|
@ -124,6 +124,7 @@ struct Info {
|
|||
bool stores_clip_distance{};
|
||||
bool stores_layer{};
|
||||
bool stores_viewport_index{};
|
||||
bool stores_viewport_mask{};
|
||||
bool stores_tess_level_outer{};
|
||||
bool stores_tess_level_inner{};
|
||||
bool stores_indexed_attributes{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue