Implement intput and output fixed fnc textures
This commit is contained in:
parent
a7bbaa4897
commit
d994466a08
|
@ -1206,10 +1206,12 @@ void EmitContext::DefineInputs(const IR::Program& program) {
|
||||||
Decorate(id, spv::Decoration::Location, static_cast<u32>(11));
|
Decorate(id, spv::Decoration::Location, static_cast<u32>(11));
|
||||||
input_front_color = id;
|
input_front_color = id;
|
||||||
}
|
}
|
||||||
if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) {
|
for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) {
|
||||||
const Id id{DefineInput(*this, F32[4], true)};
|
if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) {
|
||||||
Decorate(id, spv::Decoration::Location, static_cast<u32>(12));
|
const Id id{DefineInput(*this, F32[4], true)};
|
||||||
input_fixed_fnc_texture = id;
|
Decorate(id, spv::Decoration::Location, static_cast<u32>(12));
|
||||||
|
input_fixed_fnc_textures[index] = id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (loads[IR::Attribute::InstanceId]) {
|
if (loads[IR::Attribute::InstanceId]) {
|
||||||
if (profile.support_vertex_instance_id) {
|
if (profile.support_vertex_instance_id) {
|
||||||
|
@ -1292,11 +1294,6 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
|
||||||
if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) {
|
if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) {
|
||||||
output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position);
|
output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position);
|
||||||
}
|
}
|
||||||
if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR) || stage == Stage::VertexB) {
|
|
||||||
const Id id{DefineOutput(*this, F32[4], invocations)};
|
|
||||||
Decorate(id, spv::Decoration::Location, static_cast<u32>(11));
|
|
||||||
output_front_color = id;
|
|
||||||
}
|
|
||||||
if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) {
|
if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) {
|
||||||
if (stage == Stage::Fragment) {
|
if (stage == Stage::Fragment) {
|
||||||
throw NotImplementedException("Storing PointSize in fragment stage");
|
throw NotImplementedException("Storing PointSize in fragment stage");
|
||||||
|
@ -1328,13 +1325,18 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
|
||||||
viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt,
|
viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt,
|
||||||
spv::BuiltIn::ViewportMaskNV);
|
spv::BuiltIn::ViewportMaskNV);
|
||||||
}
|
}
|
||||||
|
if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR) || stage == Stage::VertexB) {
|
||||||
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>(11));
|
||||||
output_fixed_fnc_texture = id;
|
output_front_color = id;
|
||||||
|
}
|
||||||
|
for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) {
|
||||||
|
if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) {
|
||||||
|
const Id id{DefineOutput(*this, F32[4], invocations)};
|
||||||
|
Decorate(id, spv::Decoration::Location, static_cast<u32>(12));
|
||||||
|
output_fixed_fnc_textures[index] = id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {
|
for (size_t index = 0; index < IR::NUM_GENERICS; ++index) {
|
||||||
if (info.stores.Generic(index)) {
|
if (info.stores.Generic(index)) {
|
||||||
DefineGenericOutput(*this, index, invocations);
|
DefineGenericOutput(*this, index, invocations);
|
||||||
|
|
|
@ -269,13 +269,13 @@ public:
|
||||||
|
|
||||||
Id input_position{};
|
Id input_position{};
|
||||||
Id input_front_color{};
|
Id input_front_color{};
|
||||||
Id input_fixed_fnc_texture{};
|
std::array<Id, 10> input_fixed_fnc_textures{};
|
||||||
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_fixed_fnc_texture;
|
std::array<Id, 10> output_fixed_fnc_textures{};
|
||||||
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{};
|
||||||
|
|
|
@ -78,7 +78,8 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) {
|
||||||
const u32 index{IR::FixedFncTextureAttributeIndex(attr)};
|
const u32 index{IR::FixedFncTextureAttributeIndex(attr)};
|
||||||
const u32 element{IR::FixedFncTextureAttributeElement(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_fixed_fnc_texture, element_id);
|
return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_textures[index],
|
||||||
|
element_id);
|
||||||
}
|
}
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case IR::Attribute::PointSize:
|
case IR::Attribute::PointSize:
|
||||||
|
@ -323,8 +324,9 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) {
|
||||||
}
|
}
|
||||||
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
|
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
|
||||||
const u32 index{IR::FixedFncTextureAttributeIndex(attr)};
|
const u32 index{IR::FixedFncTextureAttributeIndex(attr)};
|
||||||
return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_fixed_fnc_texture,
|
return ctx.OpLoad(ctx.F32[1],
|
||||||
ctx.Const(element)));
|
AttrPointer(ctx, ctx.input_f32, vertex,
|
||||||
|
ctx.input_fixed_fnc_textures[index], ctx.Const(element)));
|
||||||
}
|
}
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case IR::Attribute::PrimitiveId:
|
case IR::Attribute::PrimitiveId:
|
||||||
|
|
|
@ -225,6 +225,8 @@ enum class Attribute : u64 {
|
||||||
constexpr size_t NUM_FIXEDFNCTEXTURE = 10;
|
constexpr size_t NUM_FIXEDFNCTEXTURE = 10;
|
||||||
constexpr size_t NUM_GENERICS = 32;
|
constexpr size_t NUM_GENERICS = 32;
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsFixedFncTexture(Attribute attribute);
|
||||||
|
|
||||||
[[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute);
|
[[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute);
|
||||||
|
|
||||||
[[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute);
|
[[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute);
|
||||||
|
|
Reference in New Issue