mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-23 22:25:42 +01:00
glasm: Properly declare attributes on geometry programs
This commit is contained in:
parent
fad139a3e6
commit
83cef0426b
@ -47,24 +47,31 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
|
|||||||
case Stage::VertexA:
|
case Stage::VertexA:
|
||||||
case Stage::VertexB:
|
case Stage::VertexB:
|
||||||
stage_name = "vertex";
|
stage_name = "vertex";
|
||||||
|
attrib_name = "vertex";
|
||||||
break;
|
break;
|
||||||
case Stage::TessellationControl:
|
case Stage::TessellationControl:
|
||||||
case Stage::TessellationEval:
|
case Stage::TessellationEval:
|
||||||
|
stage_name = "primitive";
|
||||||
|
attrib_name = "primitive";
|
||||||
|
break;
|
||||||
case Stage::Geometry:
|
case Stage::Geometry:
|
||||||
stage_name = "primitive";
|
stage_name = "primitive";
|
||||||
|
attrib_name = "vertex";
|
||||||
break;
|
break;
|
||||||
case Stage::Fragment:
|
case Stage::Fragment:
|
||||||
stage_name = "fragment";
|
stage_name = "fragment";
|
||||||
|
attrib_name = "fragment";
|
||||||
break;
|
break;
|
||||||
case Stage::Compute:
|
case Stage::Compute:
|
||||||
stage_name = "invocation";
|
stage_name = "invocation";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"};
|
||||||
for (size_t index = 0; index < program.info.input_generics.size(); ++index) {
|
for (size_t index = 0; index < program.info.input_generics.size(); ++index) {
|
||||||
const auto& generic{program.info.input_generics[index]};
|
const auto& generic{program.info.input_generics[index]};
|
||||||
if (generic.used) {
|
if (generic.used) {
|
||||||
Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};",
|
Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};",
|
||||||
InterpDecorator(generic.interpolation), index, stage_name, index, index);
|
InterpDecorator(generic.interpolation), index, attr_stage, index, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) {
|
for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) {
|
||||||
|
@ -66,6 +66,7 @@ public:
|
|||||||
|
|
||||||
Stage stage{};
|
Stage stage{};
|
||||||
std::string_view stage_name = "invalid";
|
std::string_view stage_name = "invalid";
|
||||||
|
std::string_view attrib_name = "invalid";
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Shader::Backend::GLASM
|
} // namespace Shader::Backend::GLASM
|
||||||
|
@ -64,20 +64,20 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr,
|
|||||||
case IR::Attribute::PositionY:
|
case IR::Attribute::PositionY:
|
||||||
case IR::Attribute::PositionZ:
|
case IR::Attribute::PositionZ:
|
||||||
case IR::Attribute::PositionW:
|
case IR::Attribute::PositionW:
|
||||||
ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.stage_name, swizzle);
|
ctx.Add("MOV.F {}.x,{}.position.{};", inst, ctx.attrib_name, swizzle);
|
||||||
break;
|
break;
|
||||||
case IR::Attribute::PointSpriteS:
|
case IR::Attribute::PointSpriteS:
|
||||||
case IR::Attribute::PointSpriteT:
|
case IR::Attribute::PointSpriteT:
|
||||||
ctx.Add("MOV.F {}.x,{}.pointcoord.{};", inst, ctx.stage_name, swizzle);
|
ctx.Add("MOV.F {}.x,{}.pointcoord.{};", inst, ctx.attrib_name, swizzle);
|
||||||
break;
|
break;
|
||||||
case IR::Attribute::InstanceId:
|
case IR::Attribute::InstanceId:
|
||||||
ctx.Add("MOV.S {}.x,{}.instance;", inst, ctx.stage_name);
|
ctx.Add("MOV.S {}.x,{}.instance;", inst, ctx.attrib_name);
|
||||||
break;
|
break;
|
||||||
case IR::Attribute::VertexId:
|
case IR::Attribute::VertexId:
|
||||||
ctx.Add("MOV.S {}.x,{}.id;", inst, ctx.stage_name);
|
ctx.Add("MOV.S {}.x,{}.id;", inst, ctx.attrib_name);
|
||||||
break;
|
break;
|
||||||
case IR::Attribute::FrontFace:
|
case IR::Attribute::FrontFace:
|
||||||
ctx.Add("CMP.S {}.x,{}.facing.x,0,-1;", inst, ctx.stage_name);
|
ctx.Add("CMP.S {}.x,{}.facing.x,0,-1;", inst, ctx.attrib_name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw NotImplementedException("Get attribute {}", attr);
|
throw NotImplementedException("Get attribute {}", attr);
|
||||||
|
Loading…
Reference in New Issue
Block a user