public override void WriteXml(StringBuilder sb, int indent, string ddsfolder) { base.WriteXml(sb, indent, ddsfolder); YtdXml.ValueTag(sb, indent, "Width", Width.ToString()); YtdXml.ValueTag(sb, indent, "Height", Height.ToString()); YtdXml.ValueTag(sb, indent, "MipLevels", Levels.ToString()); YtdXml.StringTag(sb, indent, "Format", Format.ToString()); YtdXml.StringTag(sb, indent, "Usage", Usage.ToString()); YtdXml.StringTag(sb, indent, "UsageFlags", UsageFlags.ToString()); YtdXml.ValueTag(sb, indent, "ExtraFlags", ExtraFlags.ToString()); YtdXml.StringTag(sb, indent, "FileName", YtdXml.XmlEscape((Name ?? "null") + ".dds")); try { if (!string.IsNullOrEmpty(ddsfolder)) { if (!Directory.Exists(ddsfolder)) { Directory.CreateDirectory(ddsfolder); } var filepath = Path.Combine(ddsfolder, (Name ?? "null") + ".dds"); var dds = DDSIO.GetDDSFile(this); File.WriteAllBytes(filepath, dds); } } catch { } }
private void InternalInitialization(Target target, UsageFlags usageFlags, int count, int stride) { if (RequiresCompute(target) && !SystemInfo.supportsComputeShaders) { throw new ArgumentException("Attempting to create a graphics buffer that requires compute shader support, but compute shaders are not supported on this platform. Target: " + target); } if (count <= 0) { throw new ArgumentException("Attempting to create a zero length graphics buffer", "count"); } if (stride <= 0) { throw new ArgumentException("Attempting to create a graphics buffer with a negative or null stride", "stride"); } if ((target & Target.Index) != 0 && stride != 2 && stride != 4) { throw new ArgumentException("Attempting to create an index buffer with an invalid stride: " + stride, "stride"); } else if (!IsVertexIndexOrCopyOnly(target) && stride % 4 != 0) { throw new ArgumentException("Stride must be a multiple of 4 unless the buffer is only used as a vertex buffer and/or index buffer ", "stride"); } var bufferSize = (long)count * stride; var maxBufferSize = SystemInfo.maxGraphicsBufferSize; if (bufferSize > maxBufferSize) { throw new ArgumentException($"The total size of the graphics buffer ({bufferSize} bytes) exceeds the maximum buffer size. Maximum supported buffer size: {maxBufferSize} bytes."); } if ((usageFlags & UsageFlags.LockBufferForWrite) != 0 && (target & Target.CopyDestination) != 0) { throw new ArgumentException("Attempting to create a LockBufferForWrite capable buffer that can be copied into. LockBufferForWrite buffers are read-only on the GPU."); } m_Ptr = InitBuffer(target, usageFlags, count, stride); }
public override int OnCalculateSize(bool force) { match1 = null; match2 = null; _lightLen = 0; _keyLen = 0; _visLen = 0; if (_name != "<null>") { if (!SetConstant) { _visLen += _entryCount.Align(32) / 8; } if (!_constants[0]) { foreach (SCN0LightNode n in Parent.Children) { if (n == this) { break; } if (!n._constants[0]) { for (int i = 0; i < FrameCount + 1; i++) { if (n.GetColors(0)[i] != GetColors(0)[i]) { break; } if (i == FrameCount) { match1 = n; } } } if (match1 != null) { break; } } if (match1 == null) { _lightLen += 4 * (FrameCount + 1); } } if (!_constants[1]) { foreach (SCN0LightNode n in Parent.Children) { if (n == this) { break; } if (!n._constants[1]) { for (int i = 0; i < FrameCount + 1; i++) { if (n.GetColors(1)[i] != GetColors(1)[i]) { break; } if (i == FrameCount) { match2 = n; } } } if (match2 != null) { break; } } if (match2 == null) { _lightLen += 4 * (FrameCount + 1); } } for (int i = 0; i < 10; i++) { if (GetKeys(i)._keyCount > 1) { _keyLen += 8 + GetKeys(i)._keyCount * 12; } } if (UsageFlags.HasFlag(UsageFlags.SpecularEnabled)) { ((SCN0Node)Parent.Parent)._specLights++; } } return(SCN0Light.Size); }
// Create a Graphics Buffer. public GraphicsBuffer(Target target, UsageFlags usageFlags, int count, int stride) { InternalInitialization(target, usageFlags, count, stride); SaveCallstack(2); }
static extern IntPtr InitBuffer(Target target, UsageFlags usageFlags, int count, int stride);
public bool GetEnabled(float frame) { return(!VisibilityEnabled ? false : ConstantVisibility?UsageFlags.HasFlag(UsageFlags.Enabled) : GetEntry((int)frame)); }
public ApiParam(string key, object value, UsageFlags usage = UsageFlags.Query) { Key = key; Value = value; Usage = usage; }