示例#1
0
 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);
 }
示例#2
0
 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);
 }
示例#3
0
 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);
 }
示例#4
0
 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);
 }
示例#5
0
 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;
 }
示例#6
0
        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);
        }
示例#7
0
 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));
 }
示例#8
0
 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);
 }
示例#9
0
 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);
 }
示例#10
0
 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));
 }
示例#11
0
 public static bool IsSet(this ResourceFlags flags, ResourceFlags value)
 {
     return((flags & value) == value);
 }
示例#12
0
 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));
 }
示例#13
0
文件: Vtf.cs 项目: Frassle/Ibasa
 public Resource(ResourceType type, ResourceFlags flags, int data)
 {
     Type = type;
     Flags = flags;
     Data = data;
 }
示例#14
0
 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)));
 }
示例#15
0
 public ResourceType(string name, ScopeType scopeType, ScopeType?readOnlyScopes, ITypeReference body, ResourceFlags flags)
 {
     Name           = name;
     ScopeType      = scopeType;
     ReadOnlyScopes = readOnlyScopes;
     Body           = body;
     Flags          = flags;
 }
示例#16
0
 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));
 }
示例#17
0
        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)));
        }
示例#18
0
 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)));
 }
示例#19
0
        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);
            }
        }
示例#20
0
 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));
 }
示例#22
0
        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);
            }
        }