shader,glasm: Implement legacy texcoord loads
This commit is contained in:
parent
cf9f88e5a7
commit
5539b13c5a
@ -37,6 +37,10 @@ bool IsInputArray(Stage stage) {
|
|||||||
std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) {
|
std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) {
|
||||||
return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : "";
|
return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 TexCoordIndex(IR::Attribute attr) {
|
||||||
|
return (static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4;
|
||||||
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
|
void EmitGetCbufU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset) {
|
||||||
@ -76,6 +80,11 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal
|
|||||||
ctx.Add("MOV.F {}.x,in_attr{}{}[0].{};", inst, index, VertexIndex(ctx, vertex), swizzle);
|
ctx.Add("MOV.F {}.x,in_attr{}{}[0].{};", inst, index, VertexIndex(ctx, vertex), swizzle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
|
||||||
|
const u32 index{TexCoordIndex(attr)};
|
||||||
|
ctx.Add("MOV.F {}.x,{}.texcoord[{}].{};", inst, ctx.attrib_name, index, swizzle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case IR::Attribute::PrimitiveId:
|
case IR::Attribute::PrimitiveId:
|
||||||
ctx.Add("MOV.S {}.x,primitive.id;", inst);
|
ctx.Add("MOV.S {}.x,primitive.id;", inst);
|
||||||
@ -128,8 +137,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, ScalarF32 value,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9R) {
|
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9R) {
|
||||||
const u32 index{
|
const u32 index{TexCoordIndex(attr)};
|
||||||
(static_cast<u32>(attr) - static_cast<u32>(IR::Attribute::FixedFncTexture0S)) / 4};
|
|
||||||
ctx.Add("MOV.F result.texcoord[{}].{},{};", index, swizzle, value);
|
ctx.Add("MOV.F result.texcoord[{}].{},{};", index, swizzle, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,16 @@ void AddConstantBufferDescriptor(Info& info, u32 index, u32 count) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAttribute(Info& info, IR::Attribute attribute) {
|
void GetAttribute(Info& info, IR::Attribute attr) {
|
||||||
if (IR::IsGeneric(attribute)) {
|
if (IR::IsGeneric(attr)) {
|
||||||
info.input_generics.at(IR::GenericAttributeIndex(attribute)).used = true;
|
info.input_generics.at(IR::GenericAttributeIndex(attr)).used = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (attribute) {
|
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
|
||||||
|
info.loads_fixed_fnc_textures = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (attr) {
|
||||||
case IR::Attribute::PrimitiveId:
|
case IR::Attribute::PrimitiveId:
|
||||||
info.loads_primitive_id = true;
|
info.loads_primitive_id = true;
|
||||||
break;
|
break;
|
||||||
@ -67,16 +71,20 @@ void GetAttribute(Info& info, IR::Attribute attribute) {
|
|||||||
info.loads_front_face = true;
|
info.loads_front_face = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw NotImplementedException("Get attribute {}", attribute);
|
throw NotImplementedException("Get attribute {}", attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAttribute(Info& info, IR::Attribute attribute) {
|
void SetAttribute(Info& info, IR::Attribute attr) {
|
||||||
if (IR::IsGeneric(attribute)) {
|
if (IR::IsGeneric(attr)) {
|
||||||
info.stores_generics.at(IR::GenericAttributeIndex(attribute)) = true;
|
info.stores_generics.at(IR::GenericAttributeIndex(attr)) = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (attribute) {
|
if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) {
|
||||||
|
info.stores_fixed_fnc_textures = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (attr) {
|
||||||
case IR::Attribute::Layer:
|
case IR::Attribute::Layer:
|
||||||
info.stores_layer = true;
|
info.stores_layer = true;
|
||||||
break;
|
break;
|
||||||
@ -116,48 +124,6 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
|
|||||||
case IR::Attribute::ColorBackSpecularA:
|
case IR::Attribute::ColorBackSpecularA:
|
||||||
info.stores_color_front_specular = true;
|
info.stores_color_front_specular = true;
|
||||||
break;
|
break;
|
||||||
case IR::Attribute::FixedFncTexture0S:
|
|
||||||
case IR::Attribute::FixedFncTexture0T:
|
|
||||||
case IR::Attribute::FixedFncTexture0R:
|
|
||||||
case IR::Attribute::FixedFncTexture0Q:
|
|
||||||
case IR::Attribute::FixedFncTexture1S:
|
|
||||||
case IR::Attribute::FixedFncTexture1T:
|
|
||||||
case IR::Attribute::FixedFncTexture1R:
|
|
||||||
case IR::Attribute::FixedFncTexture1Q:
|
|
||||||
case IR::Attribute::FixedFncTexture2S:
|
|
||||||
case IR::Attribute::FixedFncTexture2T:
|
|
||||||
case IR::Attribute::FixedFncTexture2R:
|
|
||||||
case IR::Attribute::FixedFncTexture2Q:
|
|
||||||
case IR::Attribute::FixedFncTexture3S:
|
|
||||||
case IR::Attribute::FixedFncTexture3T:
|
|
||||||
case IR::Attribute::FixedFncTexture3R:
|
|
||||||
case IR::Attribute::FixedFncTexture3Q:
|
|
||||||
case IR::Attribute::FixedFncTexture4S:
|
|
||||||
case IR::Attribute::FixedFncTexture4T:
|
|
||||||
case IR::Attribute::FixedFncTexture4R:
|
|
||||||
case IR::Attribute::FixedFncTexture4Q:
|
|
||||||
case IR::Attribute::FixedFncTexture5S:
|
|
||||||
case IR::Attribute::FixedFncTexture5T:
|
|
||||||
case IR::Attribute::FixedFncTexture5R:
|
|
||||||
case IR::Attribute::FixedFncTexture5Q:
|
|
||||||
case IR::Attribute::FixedFncTexture6S:
|
|
||||||
case IR::Attribute::FixedFncTexture6T:
|
|
||||||
case IR::Attribute::FixedFncTexture6R:
|
|
||||||
case IR::Attribute::FixedFncTexture6Q:
|
|
||||||
case IR::Attribute::FixedFncTexture7S:
|
|
||||||
case IR::Attribute::FixedFncTexture7T:
|
|
||||||
case IR::Attribute::FixedFncTexture7R:
|
|
||||||
case IR::Attribute::FixedFncTexture7Q:
|
|
||||||
case IR::Attribute::FixedFncTexture8S:
|
|
||||||
case IR::Attribute::FixedFncTexture8T:
|
|
||||||
case IR::Attribute::FixedFncTexture8R:
|
|
||||||
case IR::Attribute::FixedFncTexture8Q:
|
|
||||||
case IR::Attribute::FixedFncTexture9S:
|
|
||||||
case IR::Attribute::FixedFncTexture9T:
|
|
||||||
case IR::Attribute::FixedFncTexture9R:
|
|
||||||
case IR::Attribute::FixedFncTexture9Q:
|
|
||||||
info.stores_fixed_fnc_textures = true;
|
|
||||||
break;
|
|
||||||
case IR::Attribute::ClipDistance0:
|
case IR::Attribute::ClipDistance0:
|
||||||
case IR::Attribute::ClipDistance1:
|
case IR::Attribute::ClipDistance1:
|
||||||
case IR::Attribute::ClipDistance2:
|
case IR::Attribute::ClipDistance2:
|
||||||
@ -175,7 +141,7 @@ void SetAttribute(Info& info, IR::Attribute attribute) {
|
|||||||
info.stores_viewport_mask = true;
|
info.stores_viewport_mask = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw NotImplementedException("Set attribute {}", attribute);
|
throw NotImplementedException("Set attribute {}", attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ struct Info {
|
|||||||
bool loads_primitive_id{};
|
bool loads_primitive_id{};
|
||||||
bool loads_position{};
|
bool loads_position{};
|
||||||
bool loads_color_front_diffuse{};
|
bool loads_color_front_diffuse{};
|
||||||
|
bool loads_fixed_fnc_textures{};
|
||||||
bool loads_point_coord{};
|
bool loads_point_coord{};
|
||||||
bool loads_instance_id{};
|
bool loads_instance_id{};
|
||||||
bool loads_vertex_id{};
|
bool loads_vertex_id{};
|
||||||
|
Loading…
Reference in New Issue
Block a user