public void Read(byte[] buffer, int offset) { CompressedSize = Utilities.ToInt64LittleEndian(buffer, offset); Flags = (ResourceFlags)((CompressedSize >> 56) & 0xFF); CompressedSize = CompressedSize & 0x00FFFFFFFFFFFFFF; FileOffset = Utilities.ToInt64LittleEndian(buffer, offset + 8); OriginalSize = Utilities.ToInt64LittleEndian(buffer, offset + 16); }
public static ResourceDescription Texture1D(DXGI.Format format, long width, short arraySize = 1, short mipLevels = 0, ResourceFlags flags = ResourceFlags.None, TextureLayout layout = TextureLayout.Unknown, long alignment = 0) { return new ResourceDescription(ResourceDimension.Texture1D, alignment, width, 1, arraySize, mipLevels, format, 1, 0, layout, flags); }
public static ResourceDescription Texture3D(DXGI.Format format, long width, int height, short depth, short mipLevels = 0, ResourceFlags flags = ResourceFlags.None, TextureLayout layout = TextureLayout.Unknown, long alignment = 0) { return new ResourceDescription(ResourceDimension.Texture3D, alignment, width, height, depth, mipLevels, format, 1, 0, layout, flags); }
public static ResourceDescription Texture2D(DXGI.Format format, long width, int height, short arraySize = 1, short mipLevels = 0, int sampleCount = 1, int sampleQuality = 0, ResourceFlags flags = ResourceFlags.None, TextureLayout layout = TextureLayout.Unknown, long alignment = 0) { return new ResourceDescription(ResourceDimension.Texture2D, alignment, width, height, arraySize, mipLevels, format, sampleCount, sampleQuality, layout, flags); }
public ResourceDescription(ResourceDimension dimension, long alignment, long width, int height, short depthOrArraySize, short mipLevels, Format format, int sampleCount, int sampleQuality, TextureLayout layout, ResourceFlags optionFlags) { Dimension = dimension; Alignment = alignment; Width = width; Height = height; DepthOrArraySize = depthOrArraySize; MipLevels = mipLevels; Format = format; SampleDescription = new SampleDescription(sampleCount, sampleQuality); Layout = layout; Flags = optionFlags; }
public static Texture New2D <T>(GraphicsDevice device, Span <T> data, int width, int height, PixelFormat format, ResourceFlags textureFlags = ResourceFlags.ShaderResource, short mipLevels = 1, short arraySize = 1, int sampleCount = 1, int sampleQuality = 0, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged { Texture texture = New2D(device, width, height, format, textureFlags, mipLevels, arraySize, sampleCount, sampleQuality, heapType); texture.SetData(data); return(texture); }
public static ResourceDescription Buffer(ResourceAllocationInfo resourceAllocInfo, ResourceFlags flags = ResourceFlags.None) { return(new ResourceDescription(ResourceDimension.Buffer, resourceAllocInfo.Alignment, resourceAllocInfo.SizeInBytes, 1, 1, 1, Format.Unknown, 1, 0, TextureLayout.RowMajor, flags)); }
public static ResourceDescription Buffer(long width, ResourceFlags flags = ResourceFlags.None, long alignment = 0) { return new ResourceDescription(ResourceDimension.Buffer, alignment, width, 1, 1, 1, DXGI.Format.Unknown, 1, 0, TextureLayout.RowMajor, flags); }
public static ResourceDescription Buffer(ResourceAllocationInformation resourceAllocInfowidth, ResourceFlags flags = ResourceFlags.None) { return new ResourceDescription(ResourceDimension.Buffer, resourceAllocInfowidth.Alignment, resourceAllocInfowidth.SizeInBytes, 1, 1, 1, DXGI.Format.Unknown, 1, 0, TextureLayout.RowMajor, flags); }
public static Texture Create2D(GraphicsDevice device, int width, int height, PixelFormat format, ResourceFlags textureFlags = ResourceFlags.None, short mipLevels = 1, short arraySize = 1, int sampleCount = 1, int sampleQuality = 0, HeapType heapType = HeapType.Default) { return(new Texture(device, ResourceDescription.Texture2D(width, height, format, textureFlags, mipLevels, arraySize, sampleCount, sampleQuality), heapType)); }
public static bool IsSet(this ResourceFlags flags, ResourceFlags value) { return((flags & value) == value); }
public static ResourceDescription Buffer(ulong width, ResourceFlags flags = ResourceFlags.None, ulong alignment = 0) { return(new ResourceDescription(ResourceDimension.Buffer, alignment, width, 1, 1, 1, Format.Unknown, 1, 0, TextureLayout.RowMajor, flags)); }
public Resource(ResourceType type, ResourceFlags flags, int data) { Type = type; Flags = flags; Data = data; }
public static Texture New2D(GraphicsDevice device, int width, int height, PixelFormat format, ResourceFlags textureFlags = ResourceFlags.ShaderResource, short mipLevels = 1, short arraySize = 1, int sampleCount = 1, int sampleQuality = 0, GraphicsHeapType heapType = GraphicsHeapType.Default) { return(New(device, TextureDescription.New2D(width, height, format, textureFlags, mipLevels, arraySize, sampleCount, sampleQuality, heapType))); }
public ResourceType(string name, ScopeType scopeType, ScopeType?readOnlyScopes, ITypeReference body, ResourceFlags flags) { Name = name; ScopeType = scopeType; ReadOnlyScopes = readOnlyScopes; Body = body; Flags = flags; }
public static GraphicsBuffer <T> New <T>(GraphicsDevice device, int elementCount, ResourceFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged { return(New <T>(device, elementCount, Unsafe.SizeOf <T>(), bufferFlags, heapType)); }
public static GraphicsBuffer <T> New <T>(GraphicsDevice device, int elementCount, int structureByteStride, ResourceFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged { int size = structureByteStride * elementCount; return(new GraphicsBuffer <T>(device, new GraphicsBufferDescription(size, bufferFlags, heapType, structureByteStride))); }
public static GraphicsBuffer New(GraphicsDevice device, int size, int structureByteStride, ResourceFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) { return(New(device, new GraphicsBufferDescription(size, bufferFlags, heapType, structureByteStride))); }
private static void WriteContentTreeSection(ContentTree.Node node, Stream tableStream, Stream dataStream, PostprocessFileCallback postprocessFileCallback) { using (BinaryWriter w = new BinaryWriter(tableStream, Encoding.UTF8, true)) { ResourceFlags flags = 0; if (node.Children.Count > 0) { flags |= ResourceFlags.HasChildren; } if (node.Source != null) { flags |= ResourceFlags.HasResource; flags &= ~ResourceFlags.External; } Stream overrideStream = null; if (postprocessFileCallback != null) { postprocessFileCallback(node, ref flags, ref overrideStream); } try { w.Write((byte)flags); w.WriteAsciiString(node.Name); if ((flags & ResourceFlags.HasChildren) != 0) { w.Write((ushort)node.Children.Count); } if ((flags & ResourceFlags.HasResource) != 0) { if ((flags & ResourceFlags.External) != 0) { if (overrideStream != null) { throw new InvalidOperationException("Cannot use overrideStream with ResourceFlags.External"); } FileResourceSource source = node.Source as FileResourceSource; if (source == null) { throw new InvalidOperationException("Specified resource must be saved as file"); } w.WriteAsciiString(source.Path); w.Write((uint)source.Offset); w.Write((uint)source.Size); } else { long offset = dataStream.Position; if (overrideStream != null) { if ((flags & ResourceFlags.Compressed) != 0) { using (DeflateStream ds = new DeflateStream(dataStream, CompressionLevel.Optimal, true)) { overrideStream.CopyTo(ds); } } else { overrideStream.CopyTo(dataStream); } } else { using (Stream stream = (flags & ResourceFlags.Compressed) != 0 ? node.Source.GetCompressedStream() : node.Source.GetUncompressedStream()) { stream.CopyTo(dataStream); } } long size = (dataStream.Position - offset); w.Write((uint)offset); w.Write((uint)size); } } } finally { if (overrideStream != null) { overrideStream.Dispose(); } } } foreach (ContentTree.Node children in node.Children) { WriteContentTreeSection(children, tableStream, dataStream, postprocessFileCallback); } }
public static TextureDesc CreateShadingRateTextureDesc(uint width, uint height, ResourceFlags flags = ResourceFlags.None) { return(new TextureDesc { Height = height, Width = width, DepthOrArraySize = 1, Dimension = TextureDimension.Tex2D, MipCount = 1, Format = DataFormat.R8UInt, Layout = TextureLayout.Optimal, Msaa = MsaaDesc.None, ResourceFlags = flags, ClearValue = null, }); }
public ID3D11Resource CreateWrappedResource(IUnknown d3d12Resource, ResourceFlags flags, int inState, int outState) { return(CreateWrappedResource(d3d12Resource, flags, inState, outState, typeof(ID3D11Resource).GUID)); }
private static void WriteContentTreeSection(ContentTree.Node node, Stream tableStream, Stream dataStream, Func <string, ResourceFlags, ResourceFlags> resourceFlagsModifier) { using (BinaryWriter w = new BinaryWriter(tableStream, Encoding.UTF8, true)) { ResourceFlags flags = 0; if (node.Children.Count > 0) { flags |= ResourceFlags.HasChildren; } if (node.Source != null) { flags |= ResourceFlags.HasResource; flags &= ~ResourceFlags.External; } if (resourceFlagsModifier != null) { flags = resourceFlagsModifier(node.Name, flags); } w.Write((byte)flags); w.WriteAsciiString(node.Name); if ((flags & ResourceFlags.HasChildren) != 0) { w.Write((ushort)node.Children.Count); } if ((flags & ResourceFlags.HasResource) != 0) { if ((flags & ResourceFlags.External) != 0) { FileResourceSource source = node.Source as FileResourceSource; w.WriteAsciiString(source.Path); w.Write((uint)source.Offset); w.Write((uint)source.Size); } else { long offset = dataStream.Position; w.Write((uint)offset); using (Stream stream = (flags & ResourceFlags.Compressed) != 0 ? node.Source.GetCompressedStream() : node.Source.GetUncompressedStream()) { stream.CopyTo(dataStream); } long size = (dataStream.Position - offset); w.Write((uint)size); } } } foreach (ContentTree.Node children in node.Children) { WriteContentTreeSection(children, tableStream, dataStream, resourceFlagsModifier); } }