public void PrepareForReturn() { if (_shaderType == GalShaderType.Fragment) { if (_header.OmapDepth) { Operand dest = Attribute(AttributeConsts.FragmentOutputDepth); Operand src = Register(_header.DepthRegister, RegisterType.Gpr); this.Copy(dest, src); } int regIndex = 0; for (int attachment = 0; attachment < 8; attachment++) { OutputMapTarget target = _header.OmapTargets[attachment]; for (int component = 0; component < 4; component++) { if (target.ComponentEnabled(component)) { Operand dest = Attribute(AttributeConsts.FragmentOutputColorBase + regIndex * 4); Operand src = Register(regIndex, RegisterType.Gpr); this.Copy(dest, src); regIndex++; } } } } }
public ShaderHeader(ReadOnlySpan <byte> code) { ReadOnlySpan <int> header = MemoryMarshal.Cast <byte, int>(code); int commonWord0 = header[0]; int commonWord1 = header[1]; int commonWord2 = header[2]; int commonWord3 = header[3]; int commonWord4 = header[4]; SphType = commonWord0.Extract(0, 5); Version = commonWord0.Extract(5, 5); Stage = (ShaderStage)commonWord0.Extract(10, 4); // Invalid. if (Stage == ShaderStage.Compute) { Stage = ShaderStage.Vertex; } MrtEnable = commonWord0.Extract(14); KillsPixels = commonWord0.Extract(15); DoesGlobalStore = commonWord0.Extract(16); SassVersion = commonWord0.Extract(17, 4); DoesLoadOrStore = commonWord0.Extract(26); DoesFp64 = commonWord0.Extract(27); StreamOutMask = commonWord0.Extract(28, 4); ShaderLocalMemoryLowSize = commonWord1.Extract(0, 24); PerPatchAttributeCount = commonWord1.Extract(24, 8); ShaderLocalMemoryHighSize = commonWord2.Extract(0, 24); ThreadsPerInputPrimitive = commonWord2.Extract(24, 8); ShaderLocalMemoryCrsSize = commonWord3.Extract(0, 24); OutputTopology = (OutputTopology)commonWord3.Extract(24, 4); MaxOutputVertexCount = commonWord4.Extract(0, 12); StoreReqStart = commonWord4.Extract(12, 8); StoreReqEnd = commonWord4.Extract(24, 8); int type2OmapTarget = header[18]; int type2Omap = header[19]; OmapTargets = new OutputMapTarget[8]; for (int offset = 0; offset < OmapTargets.Length * 4; offset += 4) { OmapTargets[offset >> 2] = new OutputMapTarget( type2OmapTarget.Extract(offset + 0), type2OmapTarget.Extract(offset + 1), type2OmapTarget.Extract(offset + 2), type2OmapTarget.Extract(offset + 3)); } OmapSampleMask = type2Omap.Extract(0); OmapDepth = type2Omap.Extract(1); }