forked from ShuriZma/suyu
1
0
Fork 0

Rename parameters

This commit is contained in:
Feng Chen 2021-09-03 23:52:20 +08:00
parent cf26f375ff
commit a7bbaa4897
5 changed files with 24 additions and 14 deletions

View File

@ -1209,7 +1209,7 @@ void EmitContext::DefineInputs(const IR::Program& program) {
if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) { if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) {
const Id id{DefineInput(*this, F32[4], true)}; const Id id{DefineInput(*this, F32[4], true)};
Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); Decorate(id, spv::Decoration::Location, static_cast<u32>(12));
input_txt_coord = id; input_fixed_fnc_texture = id;
} }
if (loads[IR::Attribute::InstanceId]) { if (loads[IR::Attribute::InstanceId]) {
if (profile.support_vertex_instance_id) { if (profile.support_vertex_instance_id) {
@ -1332,7 +1332,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) { if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) {
const Id id{DefineOutput(*this, F32[4], invocations)}; const Id id{DefineOutput(*this, F32[4], invocations)};
Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); Decorate(id, spv::Decoration::Location, static_cast<u32>(12));
output_txt_coord = id; output_fixed_fnc_texture = id;
} }
for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {

View File

@ -269,13 +269,13 @@ public:
Id input_position{}; Id input_position{};
Id input_front_color{}; Id input_front_color{};
Id input_txt_coord{}; Id input_fixed_fnc_texture{};
std::array<Id, 32> input_generics{}; std::array<Id, 32> input_generics{};
Id output_point_size{}; Id output_point_size{};
Id output_position{}; Id output_position{};
Id output_front_color{}; Id output_front_color{};
Id output_txt_coord; Id output_fixed_fnc_texture;
std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; std::array<std::array<GenericElementInfo, 4>, 32> output_generics{};
Id output_tess_level_outer{}; Id output_tess_level_outer{};

View File

@ -75,10 +75,10 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) {
} }
} }
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
const u32 index{IR::TxtCoordAttributeIndex(attr)}; const u32 index{IR::FixedFncTextureAttributeIndex(attr)};
const u32 element{IR::TxtCoordAttributeElement(attr)}; const u32 element{IR::FixedFncTextureAttributeElement(attr)};
const Id element_id{ctx.Const(element)}; const Id element_id{ctx.Const(element)};
return OutputAccessChain(ctx, ctx.output_f32, ctx.output_txt_coord, element_id); return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_texture, element_id);
} }
switch (attr) { switch (attr) {
case IR::Attribute::PointSize: case IR::Attribute::PointSize:
@ -322,8 +322,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) {
return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value;
} }
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
const u32 index{IR::TxtCoordAttributeIndex(attr)}; const u32 index{IR::FixedFncTextureAttributeIndex(attr)};
return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_txt_coord, return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_fixed_fnc_texture,
ctx.Const(element))); ctx.Const(element)));
} }
switch (attr) { switch (attr) {

View File

@ -9,11 +9,21 @@
namespace Shader::IR { namespace Shader::IR {
u32 TxtCoordAttributeIndex(Attribute attribute) { bool IsFixedFncTexture(Attribute attribute) {
return attribute >= Attribute::FixedFncTexture0S && attribute <= Attribute::FixedFncTexture9Q;
}
u32 FixedFncTextureAttributeIndex(Attribute attribute) {
if (!IsFixedFncTexture(attribute)) {
throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute);
}
return (static_cast<u32>(attribute) - static_cast<u32>(Attribute::FixedFncTexture0S)) / 4u; return (static_cast<u32>(attribute) - static_cast<u32>(Attribute::FixedFncTexture0S)) / 4u;
} }
u32 TxtCoordAttributeElement(Attribute attribute) { u32 FixedFncTextureAttributeElement(Attribute attribute) {
if (!IsFixedFncTexture(attribute)) {
throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute);
}
return static_cast<u32>(attribute) % 4; return static_cast<u32>(attribute) % 4;
} }

View File

@ -222,12 +222,12 @@ enum class Attribute : u64 {
FrontFace = 255, FrontFace = 255,
}; };
constexpr size_t NUM_TXT_COORD = 10; constexpr size_t NUM_FIXEDFNCTEXTURE = 10;
constexpr size_t NUM_GENERICS = 32; constexpr size_t NUM_GENERICS = 32;
[[nodiscard]] u32 TxtCoordAttributeIndex(Attribute attribute); [[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute);
[[nodiscard]] u32 TxtCoordAttributeElement(Attribute attribute); [[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute);
[[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept;