forked from ShuriZma/suyu
shader: Add PointCoord attribute
This commit is contained in:
parent
b7589fe115
commit
9d7422d967
|
@ -425,6 +425,9 @@ void EmitContext::DefineInputs(const Info& info) {
|
||||||
if (info.loads_front_face) {
|
if (info.loads_front_face) {
|
||||||
front_face = DefineInput(*this, U1, spv::BuiltIn::FrontFacing);
|
front_face = DefineInput(*this, U1, spv::BuiltIn::FrontFacing);
|
||||||
}
|
}
|
||||||
|
if (info.loads_point_coord) {
|
||||||
|
point_coord = DefineInput(*this, F32[2], spv::BuiltIn::PointCoord);
|
||||||
|
}
|
||||||
for (size_t index = 0; index < info.input_generics.size(); ++index) {
|
for (size_t index = 0; index < info.input_generics.size(); ++index) {
|
||||||
const InputVarying generic{info.input_generics[index]};
|
const InputVarying generic{info.input_generics[index]};
|
||||||
if (!generic.used) {
|
if (!generic.used) {
|
||||||
|
|
|
@ -103,6 +103,8 @@ public:
|
||||||
Id vertex_index{};
|
Id vertex_index{};
|
||||||
Id base_vertex{};
|
Id base_vertex{};
|
||||||
Id front_face{};
|
Id front_face{};
|
||||||
|
Id point_coord{};
|
||||||
|
|
||||||
Id fswzadd_lut_a{};
|
Id fswzadd_lut_a{};
|
||||||
Id fswzadd_lut_b{};
|
Id fswzadd_lut_b{};
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,12 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr) {
|
||||||
return ctx.OpSelect(ctx.U32[1], ctx.OpLoad(ctx.U1, ctx.front_face),
|
return ctx.OpSelect(ctx.U32[1], ctx.OpLoad(ctx.U1, ctx.front_face),
|
||||||
ctx.Constant(ctx.U32[1], std::numeric_limits<u32>::max()),
|
ctx.Constant(ctx.U32[1], std::numeric_limits<u32>::max()),
|
||||||
ctx.u32_zero_value);
|
ctx.u32_zero_value);
|
||||||
|
case IR::Attribute::PointSpriteS:
|
||||||
|
return ctx.OpLoad(ctx.F32[1], ctx.OpAccessChain(ctx.input_f32, ctx.point_coord,
|
||||||
|
ctx.Constant(ctx.U32[1], 0U)));
|
||||||
|
case IR::Attribute::PointSpriteT:
|
||||||
|
return ctx.OpLoad(ctx.F32[1], ctx.OpAccessChain(ctx.input_f32, ctx.point_coord,
|
||||||
|
ctx.Constant(ctx.U32[1], 1U)));
|
||||||
default:
|
default:
|
||||||
throw NotImplementedException("Read attribute {}", attr);
|
throw NotImplementedException("Read attribute {}", attr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@ void GetAttribute(Info& info, IR::Attribute attribute) {
|
||||||
case IR::Attribute::FrontFace:
|
case IR::Attribute::FrontFace:
|
||||||
info.loads_front_face = true;
|
info.loads_front_face = true;
|
||||||
break;
|
break;
|
||||||
|
case IR::Attribute::PointSpriteS:
|
||||||
|
case IR::Attribute::PointSpriteT:
|
||||||
|
info.loads_point_coord = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw NotImplementedException("Get attribute {}", attribute);
|
throw NotImplementedException("Get attribute {}", attribute);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ struct Info {
|
||||||
bool loads_instance_id{};
|
bool loads_instance_id{};
|
||||||
bool loads_vertex_id{};
|
bool loads_vertex_id{};
|
||||||
bool loads_front_face{};
|
bool loads_front_face{};
|
||||||
|
bool loads_point_coord{};
|
||||||
|
|
||||||
std::array<bool, 8> stores_frag_color{};
|
std::array<bool, 8> stores_frag_color{};
|
||||||
bool stores_frag_depth{};
|
bool stores_frag_depth{};
|
||||||
|
|
Loading…
Reference in New Issue