public VertexInputAttribute[] GetVertexInputs() { if (LogLoaded) { if (IsLogD3D11) { uint[] byteOffs = new uint[128]; for (int i = 0; i < 128; i++) { byteOffs[i] = 0; } var layouts = m_D3D11.m_IA.layouts; VertexInputAttribute[] ret = new VertexInputAttribute[layouts.Length]; for (int i = 0; i < layouts.Length; i++) { bool needsSemanticIdx = false; for (int j = 0; j < layouts.Length; j++) { if (i != j && layouts[i].SemanticName == layouts[j].SemanticName) { needsSemanticIdx = true; break; } } uint offs = layouts[i].ByteOffset; if (offs == uint.MaxValue) // APPEND_ALIGNED { offs = byteOffs[layouts[i].InputSlot]; } else { byteOffs[layouts[i].InputSlot] = offs = layouts[i].ByteOffset; } byteOffs[layouts[i].InputSlot] += layouts[i].Format.compByteWidth * layouts[i].Format.compCount; ret[i].Name = layouts[i].SemanticName + (needsSemanticIdx ? layouts[i].SemanticIndex.ToString() : ""); ret[i].VertexBuffer = (int)layouts[i].InputSlot; ret[i].RelativeByteOffset = offs; ret[i].PerInstance = layouts[i].PerInstance; ret[i].InstanceRate = (int)layouts[i].InstanceDataStepRate; ret[i].Format = layouts[i].Format; ret[i].GenericValue = null; ret[i].Used = false; if (m_D3D11.m_IA.Bytecode != null) { for (int ia = 0; ia < m_D3D11.m_IA.Bytecode.InputSig.Length; ia++) { if (m_D3D11.m_IA.Bytecode.InputSig[ia].semanticName.ToUpperInvariant() == layouts[i].SemanticName.ToUpperInvariant() && m_D3D11.m_IA.Bytecode.InputSig[ia].semanticIndex == layouts[i].SemanticIndex) { ret[i].Used = true; break; } } } } return(ret); } else if (IsLogGL) { var attrs = m_GL.m_VtxIn.attributes; int num = 0; for (int i = 0; i < attrs.Length; i++) { int attrib = -1; if (m_GL.m_VS.BindpointMapping != null && m_GL.m_VS.ShaderDetails != null) { attrib = m_GL.m_VS.BindpointMapping.InputAttributes[i]; } else { attrib = i; } if (attrib >= 0) { num++; } } int a = 0; VertexInputAttribute[] ret = new VertexInputAttribute[num]; for (int i = 0; i < attrs.Length && a < num; i++) { ret[a].Name = String.Format("attr{0}", i); ret[a].GenericValue = null; ret[a].VertexBuffer = (int)attrs[i].BufferSlot; ret[a].RelativeByteOffset = attrs[i].RelativeOffset; ret[a].PerInstance = m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor > 0; ret[a].InstanceRate = (int)m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor; ret[a].Format = attrs[i].Format; ret[a].Used = true; if (m_GL.m_VS.BindpointMapping != null && m_GL.m_VS.ShaderDetails != null) { int attrib = m_GL.m_VS.BindpointMapping.InputAttributes[i]; if (attrib >= 0 && attrib < m_GL.m_VS.ShaderDetails.InputSig.Length) { ret[a].Name = m_GL.m_VS.ShaderDetails.InputSig[attrib].varName; } if (attrib == -1) { continue; } if (!attrs[i].Enabled) { uint compCount = m_GL.m_VS.ShaderDetails.InputSig[attrib].compCount; FormatComponentType compType = m_GL.m_VS.ShaderDetails.InputSig[attrib].compType; ret[a].GenericValue = new object[compCount]; for (uint c = 0; c < compCount; c++) { if (compType == FormatComponentType.Float) { ret[a].GenericValue[c] = attrs[i].GenericValue.f[c]; } else if (compType == FormatComponentType.UInt) { ret[a].GenericValue[c] = attrs[i].GenericValue.u[c]; } else if (compType == FormatComponentType.SInt) { ret[a].GenericValue[c] = attrs[i].GenericValue.i[c]; } } ret[a].PerInstance = false; ret[a].InstanceRate = 0; ret[a].Format.compByteWidth = 4; ret[a].Format.compCount = compCount; ret[a].Format.compType = compType; ret[a].Format.special = false; ret[a].Format.srgbCorrected = false; } } a++; } return(ret); } else if (IsLogVK) { var attrs = m_Vulkan.VI.attrs; int num = 0; for (int i = 0; i < attrs.Length; i++) { int attrib = -1; if (m_Vulkan.VS.BindpointMapping != null && m_Vulkan.VS.ShaderDetails != null) { attrib = m_Vulkan.VS.BindpointMapping.InputAttributes[attrs[i].location]; } else { attrib = i; } if (attrib >= 0) { num++; } } int a = 0; VertexInputAttribute[] ret = new VertexInputAttribute[num]; for (int i = 0; i < attrs.Length && a < num; i++) { ret[a].Name = String.Format("attr{0}", i); ret[a].GenericValue = null; ret[a].VertexBuffer = (int)attrs[i].binding; ret[a].RelativeByteOffset = attrs[i].byteoffset; ret[a].PerInstance = m_Vulkan.VI.binds[attrs[i].binding].perInstance; ret[a].InstanceRate = 1; ret[a].Format = attrs[i].format; ret[a].Used = true; if (m_Vulkan.VS.BindpointMapping != null && m_Vulkan.VS.ShaderDetails != null) { int attrib = m_Vulkan.VS.BindpointMapping.InputAttributes[attrs[i].location]; if (attrib >= 0 && attrib < m_Vulkan.VS.ShaderDetails.InputSig.Length) { ret[a].Name = m_Vulkan.VS.ShaderDetails.InputSig[attrib].varName; } if (attrib == -1) { continue; } } a++; } return(ret); } } return(null); }
public VertexInputAttribute[] GetVertexInputs() { if (LogLoaded) { if (IsLogD3D11) { uint[] byteOffs = new uint[128]; for (int i = 0; i < 128; i++) byteOffs[i] = 0; var layouts = m_D3D11.m_IA.layouts; VertexInputAttribute[] ret = new VertexInputAttribute[layouts.Length]; for (int i = 0; i < layouts.Length; i++) { bool needsSemanticIdx = false; for (int j = 0; j < layouts.Length; j++) { if (i != j && layouts[i].SemanticName == layouts[j].SemanticName) { needsSemanticIdx = true; break; } } uint offs = layouts[i].ByteOffset; if (offs == uint.MaxValue) // APPEND_ALIGNED offs = byteOffs[layouts[i].InputSlot]; else byteOffs[layouts[i].InputSlot] = offs = layouts[i].ByteOffset; byteOffs[layouts[i].InputSlot] += layouts[i].Format.compByteWidth * layouts[i].Format.compCount; ret[i].Name = layouts[i].SemanticName + (needsSemanticIdx ? layouts[i].SemanticIndex.ToString() : ""); ret[i].VertexBuffer = (int)layouts[i].InputSlot; ret[i].RelativeByteOffset = offs; ret[i].PerInstance = layouts[i].PerInstance; ret[i].InstanceRate = (int)layouts[i].InstanceDataStepRate; ret[i].Format = layouts[i].Format; } return ret; } else if (IsLogGL) { var attrs = m_GL.m_VtxIn.attributes; int num = 0; for (int i = 0; i < attrs.Length; i++) { if (attrs[i].Enabled) num++; } int a = 0; VertexInputAttribute[] ret = new VertexInputAttribute[num]; for (int i = 0; i < attrs.Length; i++) { if (!attrs[i].Enabled) continue; ret[a].Name = String.Format("attr{0}", i); ret[a].VertexBuffer = (int)attrs[i].BufferSlot; ret[a].RelativeByteOffset = attrs[i].RelativeOffset; ret[a].PerInstance = m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].PerInstance; ret[a].InstanceRate = (int)m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor; ret[a].Format = attrs[i].Format; a++; } return ret; } } return null; }
public VertexInputAttribute[] GetVertexInputs() { if (LogLoaded) { if (IsLogD3D11) { uint[] byteOffs = new uint[128]; for (int i = 0; i < 128; i++) { byteOffs[i] = 0; } var layouts = m_D3D11.m_IA.layouts; VertexInputAttribute[] ret = new VertexInputAttribute[layouts.Length]; for (int i = 0; i < layouts.Length; i++) { bool needsSemanticIdx = false; for (int j = 0; j < layouts.Length; j++) { if (i != j && layouts[i].SemanticName == layouts[j].SemanticName) { needsSemanticIdx = true; break; } } uint offs = layouts[i].ByteOffset; if (offs == uint.MaxValue) // APPEND_ALIGNED { offs = byteOffs[layouts[i].InputSlot]; } else { byteOffs[layouts[i].InputSlot] = offs = layouts[i].ByteOffset; } byteOffs[layouts[i].InputSlot] += layouts[i].Format.compByteWidth * layouts[i].Format.compCount; ret[i].Name = layouts[i].SemanticName + (needsSemanticIdx ? layouts[i].SemanticIndex.ToString() : ""); ret[i].VertexBuffer = (int)layouts[i].InputSlot; ret[i].RelativeByteOffset = offs; ret[i].PerInstance = layouts[i].PerInstance; ret[i].InstanceRate = (int)layouts[i].InstanceDataStepRate; ret[i].Format = layouts[i].Format; } return(ret); } else if (IsLogGL) { var attrs = m_GL.m_VtxIn.attributes; int num = 0; for (int i = 0; i < attrs.Length; i++) { if (attrs[i].Enabled) { num++; } } int a = 0; VertexInputAttribute[] ret = new VertexInputAttribute[num]; for (int i = 0; i < attrs.Length; i++) { if (!attrs[i].Enabled) { continue; } ret[a].Name = String.Format("attr{0}", i); ret[a].VertexBuffer = (int)attrs[i].BufferSlot; ret[a].RelativeByteOffset = attrs[i].RelativeOffset; ret[a].PerInstance = m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].PerInstance; ret[a].InstanceRate = (int)m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor; ret[a].Format = attrs[i].Format; a++; } return(ret); } } return(null); }
public VertexInputAttribute[] GetVertexInputs() { if (LogLoaded) { if (IsLogD3D11) { uint[] byteOffs = new uint[128]; for (int i = 0; i < 128; i++) byteOffs[i] = 0; var layouts = m_D3D11.m_IA.layouts; VertexInputAttribute[] ret = new VertexInputAttribute[layouts.Length]; for (int i = 0; i < layouts.Length; i++) { bool needsSemanticIdx = false; for (int j = 0; j < layouts.Length; j++) { if (i != j && layouts[i].SemanticName == layouts[j].SemanticName) { needsSemanticIdx = true; break; } } uint offs = layouts[i].ByteOffset; if (offs == uint.MaxValue) // APPEND_ALIGNED offs = byteOffs[layouts[i].InputSlot]; else byteOffs[layouts[i].InputSlot] = offs = layouts[i].ByteOffset; byteOffs[layouts[i].InputSlot] += layouts[i].Format.compByteWidth * layouts[i].Format.compCount; ret[i].Name = layouts[i].SemanticName + (needsSemanticIdx ? layouts[i].SemanticIndex.ToString() : ""); ret[i].VertexBuffer = (int)layouts[i].InputSlot; ret[i].RelativeByteOffset = offs; ret[i].PerInstance = layouts[i].PerInstance; ret[i].InstanceRate = (int)layouts[i].InstanceDataStepRate; ret[i].Format = layouts[i].Format; ret[i].GenericValue = null; ret[i].Used = false; if (m_D3D11.m_IA.Bytecode != null) { for (int ia = 0; ia < m_D3D11.m_IA.Bytecode.InputSig.Length; ia++) { if (m_D3D11.m_IA.Bytecode.InputSig[ia].semanticName.ToUpperInvariant() == layouts[i].SemanticName.ToUpperInvariant() && m_D3D11.m_IA.Bytecode.InputSig[ia].semanticIndex == layouts[i].SemanticIndex) { ret[i].Used = true; break; } } } } return ret; } else if (IsLogGL) { var attrs = m_GL.m_VtxIn.attributes; int num = 0; for (int i = 0; i < attrs.Length; i++) { int attrib = -1; if (m_GL.m_VS.BindpointMapping != null && m_GL.m_VS.ShaderDetails != null) attrib = m_GL.m_VS.BindpointMapping.InputAttributes[i]; else attrib = i; if (attrib >= 0) num++; } int a = 0; VertexInputAttribute[] ret = new VertexInputAttribute[num]; for (int i = 0; i < attrs.Length && a < num; i++) { ret[a].Name = String.Format("attr{0}", i); ret[a].GenericValue = null; ret[a].VertexBuffer = (int)attrs[i].BufferSlot; ret[a].RelativeByteOffset = attrs[i].RelativeOffset; ret[a].PerInstance = m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor > 0; ret[a].InstanceRate = (int)m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor; ret[a].Format = attrs[i].Format; ret[a].Used = true; if (m_GL.m_VS.BindpointMapping != null && m_GL.m_VS.ShaderDetails != null) { int attrib = m_GL.m_VS.BindpointMapping.InputAttributes[i]; if (attrib >= 0 && attrib < m_GL.m_VS.ShaderDetails.InputSig.Length) ret[a].Name = m_GL.m_VS.ShaderDetails.InputSig[attrib].varName; if (attrib == -1) continue; if (!attrs[i].Enabled) { uint compCount = m_GL.m_VS.ShaderDetails.InputSig[attrib].compCount; FormatComponentType compType = m_GL.m_VS.ShaderDetails.InputSig[attrib].compType; ret[a].GenericValue = new object[compCount]; for (uint c = 0; c < compCount; c++) { if (compType == FormatComponentType.Float) ret[a].GenericValue[c] = attrs[i].GenericValue.f[c]; else if (compType == FormatComponentType.UInt) ret[a].GenericValue[c] = attrs[i].GenericValue.u[c]; else if (compType == FormatComponentType.SInt) ret[a].GenericValue[c] = attrs[i].GenericValue.i[c]; else if (compType == FormatComponentType.UScaled) ret[a].GenericValue[c] = (float)attrs[i].GenericValue.u[c]; else if (compType == FormatComponentType.SScaled) ret[a].GenericValue[c] = (float)attrs[i].GenericValue.i[c]; } ret[a].PerInstance = false; ret[a].InstanceRate = 0; ret[a].Format.compByteWidth = 4; ret[a].Format.compCount = compCount; ret[a].Format.compType = compType; ret[a].Format.special = false; ret[a].Format.srgbCorrected = false; } } a++; } return ret; } else if (IsLogVK) { var attrs = m_Vulkan.VI.attrs; int num = 0; for (int i = 0; i < attrs.Length; i++) { int attrib = -1; if (m_Vulkan.VS.BindpointMapping != null && m_Vulkan.VS.ShaderDetails != null) { if(attrs[i].location < m_Vulkan.VS.BindpointMapping.InputAttributes.Length) attrib = m_Vulkan.VS.BindpointMapping.InputAttributes[attrs[i].location]; } else attrib = i; if (attrib >= 0) num++; } int a = 0; VertexInputAttribute[] ret = new VertexInputAttribute[num]; for (int i = 0; i < attrs.Length && a < num; i++) { ret[a].Name = String.Format("attr{0}", i); ret[a].GenericValue = null; ret[a].VertexBuffer = (int)attrs[i].binding; ret[a].RelativeByteOffset = attrs[i].byteoffset; ret[a].PerInstance = false; if(attrs[i].binding < m_Vulkan.VI.binds.Length) ret[a].PerInstance = m_Vulkan.VI.binds[attrs[i].binding].perInstance; ret[a].InstanceRate = 1; ret[a].Format = attrs[i].format; ret[a].Used = true; if (m_Vulkan.VS.BindpointMapping != null && m_Vulkan.VS.ShaderDetails != null) { int attrib = -1; if (attrs[i].location < m_Vulkan.VS.BindpointMapping.InputAttributes.Length) attrib = m_Vulkan.VS.BindpointMapping.InputAttributes[attrs[i].location]; if (attrib >= 0 && attrib < m_Vulkan.VS.ShaderDetails.InputSig.Length) ret[a].Name = m_Vulkan.VS.ShaderDetails.InputSig[attrib].varName; if (attrib == -1) continue; } a++; } return ret; } } return null; }