shader: Add PointSize attribute

This commit is contained in:
ameerj 2021-03-26 18:52:06 -04:00
parent 514a6b07ee
commit b7589fe115
5 changed files with 13 additions and 0 deletions

View file

@ -492,6 +492,12 @@ void EmitContext::DefineOutputs(const Info& info) {
if (info.stores_position || stage == Stage::VertexB) {
output_position = DefineOutput(*this, F32[4], spv::BuiltIn::Position);
}
if (info.stores_point_size) {
if (stage == Stage::Fragment) {
throw NotImplementedException("Storing PointSize in Fragment stage");
}
output_point_size = DefineOutput(*this, F32[1], spv::BuiltIn::PointSize);
}
for (size_t i = 0; i < info.stores_generics.size(); ++i) {
if (info.stores_generics[i]) {
output_generics[i] = DefineOutput(*this, F32[4]);

View file

@ -120,6 +120,7 @@ public:
Id input_position{};
std::array<Id, 32> input_generics{};
Id output_point_size{};
Id output_position{};
std::array<Id, 32> output_generics{};

View file

@ -37,6 +37,8 @@ Id OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) {
return ctx.OpAccessChain(ctx.output_f32, ctx.output_generics.at(index), element_id());
}
switch (attr) {
case IR::Attribute::PointSize:
return ctx.output_point_size;
case IR::Attribute::PositionX:
case IR::Attribute::PositionY:
case IR::Attribute::PositionZ:

View file

@ -58,6 +58,9 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
return;
}
switch (attribute) {
case IR::Attribute::PointSize:
info.stores_point_size = true;
break;
case IR::Attribute::PositionX:
case IR::Attribute::PositionY:
case IR::Attribute::PositionZ:

View file

@ -79,6 +79,7 @@ struct Info {
bool stores_frag_depth{};
std::array<bool, 32> stores_generics{};
bool stores_position{};
bool stores_point_size{};
bool uses_fp16{};
bool uses_fp64{};