shader: Fix disabled and unwritten attributes and varyings
This commit is contained in:
		| @@ -179,8 +179,12 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | ||||
|     const char swizzle{"xyzw"[element]}; | ||||
|     if (IR::IsGeneric(attr)) { | ||||
|         const u32 index{IR::GenericAttributeIndex(attr)}; | ||||
|         if (!ctx.runtime_info.previous_stage_stores.Generic(index)) { | ||||
|             ctx.AddF32("{}=0.f;", inst, attr); | ||||
|         if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) { | ||||
|             if (element == 3) { | ||||
|                 ctx.AddF32("{}=1.f;", inst, attr); | ||||
|             } else { | ||||
|                 ctx.AddF32("{}=0.f;", inst, attr); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         ctx.AddF32("{}=in_attr{}{}.{};", inst, index, InputVertexIndex(ctx, vertex), swizzle); | ||||
|   | ||||
| @@ -298,10 +298,14 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | ||||
|     if (IR::IsGeneric(attr)) { | ||||
|         const u32 index{IR::GenericAttributeIndex(attr)}; | ||||
|         const std::optional<AttrInfo> type{AttrTypes(ctx, index)}; | ||||
|         if (!type || !ctx.runtime_info.previous_stage_stores.Generic(index)) { | ||||
|         if (!type) { | ||||
|             // Attribute is disabled | ||||
|             return ctx.Const(0.0f); | ||||
|         } | ||||
|         if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) { | ||||
|             // Varying component is not written | ||||
|             return ctx.Const(type && element == 3 ? 1.0f : 0.0f); | ||||
|         } | ||||
|         const Id generic_id{ctx.input_generics.at(index)}; | ||||
|         const Id pointer{AttrPointer(ctx, type->pointer, vertex, generic_id, ctx.Const(element))}; | ||||
|         const Id value{ctx.OpLoad(type->id, pointer)}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user