public void IASetIndexBuffer([NativeTypeName("ID3D10Buffer *")] ID3D10Buffer *pIndexBuffer, DXGI_FORMAT Format, [NativeTypeName("UINT")] uint Offset) { ((delegate * unmanaged <ID3D10Device1 *, ID3D10Buffer *, DXGI_FORMAT, uint, void>)(lpVtbl[13]))((ID3D10Device1 *)Unsafe.AsPointer(ref this), pIndexBuffer, Format, Offset); }
private extern static uint dxtInitializeCube(IntPtr img, DXGI_FORMAT fmt, int width, int height, int nCubes, int mipLevels );
public HRESULT Initialize3D(DXGI_FORMAT fmt, int width, int height, int depth, int mipLevels) { return Utilities.HandleHRESULT(dxtInitialize3D(ptr, fmt, width, height, depth, mipLevels)); }
public static HRESULT Convert(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, ScratchImage cImages) { return HandleHRESULT(dxtConvertArray(srcImages, nimages, ref metadata, format, filter, threshold, cImages.ptr)); }
public static HRESULT Decompress(DxtImage[] cImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, ScratchImage images) { return HandleHRESULT(dxtDecompressArray(cImages, nimages, ref metadata, format, images.ptr)); }
private extern static uint dxtCompress(ref DxtImage srcImage, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, IntPtr cImage);
private extern static uint dxtComputeNormalMap(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, IntPtr normalMaps );
public int ResizeBuffers1([NativeTypeName("UINT")] uint BufferCount, [NativeTypeName("UINT")] uint Width, [NativeTypeName("UINT")] uint Height, DXGI_FORMAT Format, [NativeTypeName("UINT")] uint SwapChainFlags, [NativeTypeName("const UINT *")] uint *pCreationNodeMask, [NativeTypeName("IUnknown *const *")] IUnknown **ppPresentQueue) { return(((delegate * unmanaged <IDXGISwapChain4 *, uint, uint, uint, DXGI_FORMAT, uint, uint *, IUnknown **, int>)(lpVtbl[39]))((IDXGISwapChain4 *)Unsafe.AsPointer(ref this), BufferCount, Width, Height, Format, SwapChainFlags, pCreationNodeMask, ppPresentQueue)); }
public int VideoProcessorGetBehaviorHints([NativeTypeName("ID3D11VideoProcessor *")] ID3D11VideoProcessor *pVideoProcessor, [NativeTypeName("UINT")] uint OutputWidth, [NativeTypeName("UINT")] uint OutputHeight, DXGI_FORMAT OutputFormat, [NativeTypeName("UINT")] uint StreamCount, [NativeTypeName("const D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT *")] D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT *pStreams, [NativeTypeName("UINT *")] uint *pBehaviorHints) { return(((delegate * unmanaged <ID3D11VideoContext1 *, ID3D11VideoProcessor *, uint, uint, DXGI_FORMAT, uint, D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT *, uint *, int>)(lpVtbl[78]))((ID3D11VideoContext1 *)Unsafe.AsPointer(ref this), pVideoProcessor, OutputWidth, OutputHeight, OutputFormat, StreamCount, pStreams, pBehaviorHints)); }
public D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION dimension, [NativeTypeName("UINT64")] ulong alignment, [NativeTypeName("UINT64")] ulong width, uint height, [NativeTypeName("UINT16")] ushort depthOrArraySize, [NativeTypeName("UINT16")] ushort mipLevels, DXGI_FORMAT format, uint sampleCount, uint sampleQuality, D3D12_TEXTURE_LAYOUT layout, D3D12_RESOURCE_FLAGS flags) { Dimension = dimension; Alignment = alignment; Width = width; Height = height; DepthOrArraySize = depthOrArraySize; MipLevels = mipLevels; Format = format; SampleDesc.Count = sampleCount; SampleDesc.Quality = sampleQuality; Layout = layout; Flags = flags; }
public int ResizeBuffers([NativeTypeName("UINT")] uint BufferCount, [NativeTypeName("UINT")] uint Width, [NativeTypeName("UINT")] uint Height, DXGI_FORMAT NewFormat, [NativeTypeName("UINT")] uint SwapChainFlags) { return(((delegate * unmanaged <IDXGISwapChain4 *, uint, uint, uint, DXGI_FORMAT, uint, int>)(lpVtbl[13]))((IDXGISwapChain4 *)Unsafe.AsPointer(ref this), BufferCount, Width, Height, NewFormat, SwapChainFlags)); }
public D3D11_RENDER_TARGET_VIEW_DESC1(ID3D11Texture1D *pTex1D, D3D11_RTV_DIMENSION viewDimension, DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN, [NativeTypeName("UINT")] uint mipSlice = 0, [NativeTypeName("UINT")] uint firstArraySlice = 0, [NativeTypeName("UINT")] uint arraySize = unchecked ((uint)-1)) { ViewDimension = viewDimension; if ((DXGI_FORMAT_UNKNOWN == format) || ((unchecked ((uint)-1) == arraySize) && (D3D11_RTV_DIMENSION_TEXTURE1DARRAY == viewDimension))) { D3D11_TEXTURE1D_DESC TexDesc; pTex1D->GetDesc(&TexDesc); if (DXGI_FORMAT_UNKNOWN == format) { format = TexDesc.Format; } if (unchecked ((uint)-1) == arraySize) { arraySize = TexDesc.ArraySize - firstArraySlice; } } Format = format; Anonymous = default; switch (viewDimension) { case D3D11_RTV_DIMENSION_TEXTURE1D: { Anonymous.Texture1D.MipSlice = mipSlice; break; } case D3D11_RTV_DIMENSION_TEXTURE1DARRAY: { Anonymous.Texture1DArray.MipSlice = mipSlice; Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; Anonymous.Texture1DArray.ArraySize = arraySize; break; } default: { break; } } }
public D3D11_RENDER_TARGET_VIEW_DESC1(D3D11_RTV_DIMENSION viewDimension, DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN, [NativeTypeName("UINT")] uint mipSlice = 0, [NativeTypeName("UINT")] uint firstArraySlice = 0, [NativeTypeName("UINT")] uint arraySize = unchecked ((uint)-1), [NativeTypeName("UINT")] uint planeSlice = 0) { Format = format; ViewDimension = viewDimension; Anonymous = default; switch (viewDimension) { case D3D11_RTV_DIMENSION_BUFFER: { Anonymous.Buffer.Anonymous1.FirstElement = mipSlice; Anonymous.Buffer.Anonymous2.NumElements = firstArraySlice; break; } case D3D11_RTV_DIMENSION_TEXTURE1D: { Anonymous.Texture1D.MipSlice = mipSlice; break; } case D3D11_RTV_DIMENSION_TEXTURE1DARRAY: { Anonymous.Texture1DArray.MipSlice = mipSlice; Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; Anonymous.Texture1DArray.ArraySize = arraySize; break; } case D3D11_RTV_DIMENSION_TEXTURE2D: { Anonymous.Texture2D.MipSlice = mipSlice; Anonymous.Texture2D.PlaneSlice = planeSlice; break; } case D3D11_RTV_DIMENSION_TEXTURE2DARRAY: { Anonymous.Texture2DArray.MipSlice = mipSlice; Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; Anonymous.Texture2DArray.ArraySize = arraySize; Anonymous.Texture2DArray.PlaneSlice = planeSlice; break; } case D3D11_RTV_DIMENSION_TEXTURE2DMS: { break; } case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY: { Anonymous.Texture2DMSArray.FirstArraySlice = firstArraySlice; Anonymous.Texture2DMSArray.ArraySize = arraySize; break; } case D3D11_RTV_DIMENSION_TEXTURE3D: { Anonymous.Texture3D.MipSlice = mipSlice; Anonymous.Texture3D.FirstWSlice = firstArraySlice; Anonymous.Texture3D.WSize = arraySize; break; } default: { break; } } }
public D3D11_DEPTH_STENCIL_VIEW_DESC(ID3D11Texture2D *pTex2D, D3D11_DSV_DIMENSION viewDimension, DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN, [NativeTypeName("UINT")] uint mipSlice = 0, [NativeTypeName("UINT")] uint firstArraySlice = 0, [NativeTypeName("UINT")] uint arraySize = unchecked ((uint)-1), [NativeTypeName("UINT")] uint flags = 0) { ViewDimension = viewDimension; Flags = flags; if ((DXGI_FORMAT_UNKNOWN == format) || ((unchecked ((uint)-1) == arraySize) && ((D3D11_DSV_DIMENSION_TEXTURE2DARRAY == viewDimension) || (D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY == viewDimension)))) { D3D11_TEXTURE2D_DESC TexDesc; pTex2D->GetDesc(&TexDesc); if (DXGI_FORMAT_UNKNOWN == format) { format = TexDesc.Format; } if (unchecked ((uint)-1 == arraySize)) { arraySize = TexDesc.ArraySize - firstArraySlice; } } Format = format; Anonymous = default; switch (viewDimension) { case D3D11_DSV_DIMENSION_TEXTURE2D: { Anonymous.Texture2D.MipSlice = mipSlice; break; } case D3D11_DSV_DIMENSION_TEXTURE2DARRAY: { Anonymous.Texture2DArray.MipSlice = mipSlice; Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; Anonymous.Texture2DArray.ArraySize = arraySize; break; } case D3D11_DSV_DIMENSION_TEXTURE2DMS: { break; } case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY: { Anonymous.Texture2DMSArray.FirstArraySlice = firstArraySlice; Anonymous.Texture2DMSArray.ArraySize = arraySize; break; } default: { break; } } }
private extern static void dxtComputePitch(DXGI_FORMAT fmt, int width, int height, out int rowPitch, out int slicePitch, CP_FLAGS flags);
public HRESULT CheckVideoProcessorFormatConversion(DXGI_FORMAT InputFormat, DXGI_COLOR_SPACE_TYPE InputColorSpace, DXGI_FORMAT OutputFormat, DXGI_COLOR_SPACE_TYPE OutputColorSpace, BOOL *pSupported) { return(((delegate * unmanaged <ID3D11VideoProcessorEnumerator1 *, DXGI_FORMAT, DXGI_COLOR_SPACE_TYPE, DXGI_FORMAT, DXGI_COLOR_SPACE_TYPE, BOOL *, int>)(lpVtbl[13]))((ID3D11VideoProcessorEnumerator1 *)Unsafe.AsPointer(ref this), InputFormat, InputColorSpace, OutputFormat, OutputColorSpace, pSupported)); }
private extern static uint dxtConvert(ref DxtImage srcImage, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, IntPtr cImage);
public HRESULT CheckVideoProcessorFormat(DXGI_FORMAT Format, uint *pFlags) { return(((delegate * unmanaged <ID3D11VideoProcessorEnumerator1 *, DXGI_FORMAT, uint *, int>)(lpVtbl[8]))((ID3D11VideoProcessorEnumerator1 *)Unsafe.AsPointer(ref this), Format, pFlags)); }
private extern static uint dxtDecompress(ref DxtImage cImage, DXGI_FORMAT format, IntPtr image);
public static ScratchImage LoadFromFile(string pathToFile, List <OPTION> options) { FileInfo fInfo = new FileInfo(pathToFile); if (!fInfo.Exists) { return(null); } ulong width = 0; ulong height = 0; ulong mipLevels = 0; DXGI_FORMAT format = DXGI_FORMAT.DXGI_FORMAT_UNKNOWN; TEX_FILTER_FLAGS dwFilter = TEX_FILTER_FLAGS.TEX_FILTER_DEFAULT; TEX_FILTER_FLAGS dwSRGB = TEX_FILTER_FLAGS.TEX_FILTER_DEFAULT; TEX_FILTER_FLAGS dwConvert = TEX_FILTER_FLAGS.TEX_FILTER_DEFAULT; TEX_COMPRESS_FLAGS dwCompress = TEX_COMPRESS_FLAGS.TEX_COMPRESS_DEFAULT; TEX_FILTER_FLAGS dwFilterOpts = TEX_FILTER_FLAGS.TEX_FILTER_DEFAULT; ulong fileType = CODEC_DDS; float alphaThreshold = TEX_THRESHOLD_DEFAULT; float alphaWeight = 1.0f; CNMAP_FLAGS dwNormalMap = CNMAP_FLAGS.CNMAP_DEFAULT; float nmapAmplitude = 1.0f; float wicQuality = -1.0f; ulong colorKey = 0; ulong dwRotateColor = 0; float paperWhiteNits = 200.0f; float preserveAlphaCoverageRef = 0.0f; uint[] swizzleElements = { 0, 1, 2, 3 }; ulong dwOptions = 0; foreach (OPTION opt in options) { switch (opt.option) { case OPTIONS.OPT_WIDTH: { if (!ulong.TryParse(opt.value, out width)) { return(null); } } break; case OPTIONS.OPT_HEIGHT: { if (!ulong.TryParse(opt.value, out height)) { return(null); } } break; case OPTIONS.OPT_MIPLEVELS: { if (!ulong.TryParse(opt.value, out mipLevels)) { return(null); } } break; case OPTIONS.OPT_FORMAT: { format = (DXGI_FORMAT)LookupByName(opt.value, pFormats); if (format == DXGI_FORMAT.DXGI_FORMAT_UNKNOWN) { format = (DXGI_FORMAT)LookupByName(opt.value, pFormatAliases); if (format == DXGI_FORMAT.DXGI_FORMAT_UNKNOWN) { return(null); } } } break; case OPTIONS.OPT_FILTER: { dwFilter = (TEX_FILTER_FLAGS)LookupByName(opt.value, pFilters); if (dwFilter == TEX_FILTER_FLAGS.TEX_FILTER_DEFAULT) { return(null); } } break; case OPTIONS.OPT_ROTATE_COLOR: { dwRotateColor = LookupByName(opt.value, pRotateColor); if (dwRotateColor == 0) { return(null); } } break; case OPTIONS.OPT_SRGBI: dwSRGB |= TEX_FILTER_FLAGS.TEX_FILTER_SRGB_IN; break; case OPTIONS.OPT_SRGBO: dwSRGB |= TEX_FILTER_FLAGS.TEX_FILTER_SRGB_OUT; break; case OPTIONS.OPT_SRGB: dwSRGB |= TEX_FILTER_FLAGS.TEX_FILTER_SRGB; break; case OPTIONS.OPT_SEPALPHA: dwFilterOpts |= TEX_FILTER_FLAGS.TEX_FILTER_SEPARATE_ALPHA; break; case OPTIONS.OPT_NO_WIC: dwFilterOpts |= TEX_FILTER_FLAGS.TEX_FILTER_FORCE_NON_WIC; break; //case OPTIONS.OPT_FILETYPE: // { // fileType = LookupByName(opt.value, pSaveFileTypes); // if (fileType == 0) // return null; // } // break; case OPTIONS.OPT_PREMUL_ALPHA: { if (TexUtils.HasFlag(dwOptions, 1UL << (int)OPTIONS.OPT_DEMUL_ALPHA)) { return(null); } //dwOptions |= (1UL << (int)OPTIONS.OPT_PREMUL_ALPHA); } break; case OPTIONS.OPT_DEMUL_ALPHA: { if (TexUtils.HasFlag(dwOptions, 1UL << (int)OPTIONS.OPT_PREMUL_ALPHA)) { return(null); } //dwOptions |= (1UL << (int)OPTIONS.OPT_DEMUL_ALPHA); } break; case OPTIONS.OPT_TA_WRAP: { if (TexUtils.HasFlag(dwFilterOpts, TEX_FILTER_FLAGS.TEX_FILTER_MIRROR)) { return(null); } dwFilterOpts |= TEX_FILTER_FLAGS.TEX_FILTER_WRAP; } break; case OPTIONS.OPT_TA_MIRROR: { if (TexUtils.HasFlag(dwFilterOpts, TEX_FILTER_FLAGS.TEX_FILTER_WRAP)) { return(null); } dwFilterOpts |= TEX_FILTER_FLAGS.TEX_FILTER_MIRROR; } break; case OPTIONS.OPT_NORMAL_MAP: { dwNormalMap = CNMAP_FLAGS.CNMAP_DEFAULT; if (opt.value.Contains('l')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_CHANNEL_LUMINANCE; } else if (opt.value.Contains('r')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_CHANNEL_RED; } else if (opt.value.Contains('g')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_CHANNEL_GREEN; } else if (opt.value.Contains('b')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_CHANNEL_BLUE; } else if (opt.value.Contains('a')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_CHANNEL_ALPHA; } else { return(null); } if (opt.value.Contains('m')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_MIRROR; } else { if (opt.value.Contains('u')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_MIRROR_U; } if (opt.value.Contains('v')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_MIRROR_V; } } if (opt.value.Contains('i')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_INVERT_SIGN; } if (opt.value.Contains('o')) { dwNormalMap |= CNMAP_FLAGS.CNMAP_COMPUTE_OCCLUSION; } } break; case OPTIONS.OPT_NORMAL_MAP_AMPLITUDE: { if (dwNormalMap == 0) { return(null); } else if (!float.TryParse(opt.value, out nmapAmplitude)) { return(null); } else if (nmapAmplitude < 0.0f) { return(null); } } break; case OPTIONS.OPT_ALPHA_THRESHOLD: { if (!float.TryParse(opt.value, out alphaThreshold)) { return(null); } else if (alphaThreshold < 0.0f) { return(null); } } break; case OPTIONS.OPT_ALPHA_WEIGHT: { if (!float.TryParse(opt.value, out alphaWeight)) { return(null); } else if (alphaWeight < 0.0f) { return(null); } } break; case OPTIONS.OPT_BC_COMPRESS: { dwCompress = TEX_COMPRESS_FLAGS.TEX_COMPRESS_DEFAULT; bool found = false; if (opt.value.Contains('u')) { dwCompress |= TEX_COMPRESS_FLAGS.TEX_COMPRESS_UNIFORM; found = true; } if (opt.value.Contains('d')) { dwCompress |= TEX_COMPRESS_FLAGS.TEX_COMPRESS_DITHER; found = true; } if (opt.value.Contains('q')) { dwCompress |= TEX_COMPRESS_FLAGS.TEX_COMPRESS_BC7_QUICK; found = true; } if (opt.value.Contains('x')) { dwCompress |= TEX_COMPRESS_FLAGS.TEX_COMPRESS_BC7_USE_3SUBSETS; found = true; } if (TexUtils.HasFlag(dwCompress, TEX_COMPRESS_FLAGS.TEX_COMPRESS_BC7_USE_3SUBSETS | TEX_COMPRESS_FLAGS.TEX_COMPRESS_BC7_QUICK)) { return(null); } if (!found) { return(null); } } break; case OPTIONS.OPT_WIC_QUALITY: { if (!float.TryParse(opt.value, out wicQuality)) { return(null); } else if (wicQuality < 0.0f || wicQuality > 1.0f) { return(null); } } break; case OPTIONS.OPT_COLORKEY: { if (!ulong.TryParse(opt.value, out colorKey)) { if (!ulong.TryParse(opt.value, System.Globalization.NumberStyles.HexNumber, null, out colorKey)) { return(null); } } colorKey &= 0xFFFFFF; } break; case OPTIONS.OPT_X2_BIAS: dwConvert |= TEX_FILTER_FLAGS.TEX_FILTER_FLOAT_X2BIAS; break; case OPTIONS.OPT_PAPER_WHITE_NITS: { if (!float.TryParse(opt.value, out paperWhiteNits)) { return(null); } else if (paperWhiteNits > 10000.0f || paperWhiteNits <= 0.0f) { return(null); } } break; case OPTIONS.OPT_PRESERVE_ALPHA_COVERAGE: { if (float.TryParse(opt.value, out preserveAlphaCoverageRef)) { return(null); } else if (preserveAlphaCoverageRef < 0.0f || preserveAlphaCoverageRef > 1.0f) { return(null); } } break; case OPTIONS.OPT_SWIZZLE: { if (opt.value == null || opt.value.Length > 4) { return(null); } else if (!ParseSwizzleMask(opt.value, out swizzleElements)) { return(null); } } break; } } var fileTypeName = LookupByValue(fileType, pSaveFileTypes); if (fileType != CODEC_DDS) { mipLevels = 1; } var ext = Path.GetExtension(fInfo.FullName).ToLower(); TexMetadata info = new TexMetadata(); ScratchImage image; if (ext == ".dds") { DDS_FLAGS ddsFlags = DDS_FLAGS.DDS_FLAGS_ALLOW_LARGE_FILES; if (TexUtils.HasFlag(dwOptions, 1U << (int)OPTIONS.OPT_DDS_DWORD_ALIGN)) { ddsFlags |= DDS_FLAGS.DDS_FLAGS_LEGACY_DWORD; } if (TexUtils.HasFlag(dwOptions, 1U << (int)OPTIONS.OPT_EXPAND_LUMINANCE)) { ddsFlags |= DDS_FLAGS.DDS_FLAGS_EXPAND_LUMINANCE; } if (TexUtils.HasFlag(dwOptions, 1U << (int)OPTIONS.OPT_DDS_BAD_DXTN_TAILS)) { ddsFlags |= DDS_FLAGS.DDS_FLAGS_BAD_DXTN_TAILS; } image = LoadFromDDSFile(pathToFile, ddsFlags, ref info); if (image == null) { return(null); } if (IsTypeless(info.format)) { if (TexUtils.HasFlag(dwOptions, 1U << (int)OPTIONS.OPT_TYPELESS_UNORM)) { info.format = MakeTypelessUNORM(info.format); } else if (TexUtils.HasFlag(dwOptions, 1U << (int)OPTIONS.OPT_TYPELESS_FLOAT)) { info.format = MakeTypelessFLOAT(info.format); } if (IsTypeless(info.format)) { return(null); } image.OverrideFormat(info.format); } } else if (ext == ".bmp") { image = LoadFromBMPEx(pathToFile, WIC_FLAGS.WIC_FLAGS_NONE | (WIC_FLAGS)dwFilter, ref info); if (image == null) { return(null); } } else if (ext == ".tga") { image = LoadFromTGAFile(pathToFile, TGA_FLAGS.TGA_FLAGS_NONE, ref info); if (image == null) { return(null); } } else if (ext == ".hdr") { image = LoadFromHDRFile(pathToFile, ref info); if (image == null) { return(null); } } else if (ext == ".ppm") { image = LoadFromPortablePixMap(pathToFile, ref info); if (image == null) { return(null); } } else if (ext == ".pfm") { image = LoadFromPortablePixMapHDR(pathToFile, ref info); if (image == null) { return(null); } } else if (ext == ".exr") { image = LoadFromEXRFile(pathToFile, ref info); if (image == null) { return(null); } } else { WIC_FLAGS wicFlags = WIC_FLAGS.WIC_FLAGS_NONE | (WIC_FLAGS)dwFilter; if (fileType == CODEC_DDS) { wicFlags |= WIC_FLAGS.WIC_FLAGS_ALL_FRAMES; } image = LoadFromWICFile(pathToFile, ref info); if (image == null) { return(null); } } return(null); }
public static bool IsCompressed(DXGI_FORMAT fmt) { return dxtIsCompressed(fmt); }
public int CheckVideoDecoderFormat([NativeTypeName("const GUID *")] Guid *pDecoderProfile, DXGI_FORMAT Format, [NativeTypeName("BOOL *")] int *pSupported) { return(((delegate * stdcall <ID3D11VideoDevice2 *, Guid *, DXGI_FORMAT, int *, int>)(lpVtbl[13]))((ID3D11VideoDevice2 *)Unsafe.AsPointer(ref this), pDecoderProfile, Format, pSupported)); }
public static HRESULT Compress(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, ScratchImage cImages) { return HandleHRESULT(dxtCompressArray(srcImages, nimages, ref metadata, format, compress, alphaRef, cImages.ptr)); }
public void ResolveSubresourceRegion([NativeTypeName("ID3D12Resource *")] ID3D12Resource *pDstResource, [NativeTypeName("UINT")] uint DstSubresource, [NativeTypeName("UINT")] uint DstX, [NativeTypeName("UINT")] uint DstY, [NativeTypeName("ID3D12Resource *")] ID3D12Resource *pSrcResource, [NativeTypeName("UINT")] uint SrcSubresource, [NativeTypeName("D3D12_RECT *")] RECT *pSrcRect, DXGI_FORMAT Format, D3D12_RESOLVE_MODE ResolveMode) { ((delegate * stdcall <ID3D12GraphicsCommandList1 *, ID3D12Resource *, uint, uint, uint, ID3D12Resource *, uint, RECT *, DXGI_FORMAT, D3D12_RESOLVE_MODE, void>)(lpVtbl[64]))((ID3D12GraphicsCommandList1 *)Unsafe.AsPointer(ref this), pDstResource, DstSubresource, DstX, DstY, pSrcResource, SrcSubresource, pSrcRect, Format, ResolveMode); }
private extern static uint dxtInitialize1D(IntPtr img, DXGI_FORMAT fmt, int length, int arraySize, int mipLevels );
/// <summary> /// Creates a DDS header from a set of information. /// </summary> /// <param name="Mips">Number of mipmaps.</param> /// <param name="Height">Height of top mipmap.</param> /// <param name="Width">Width of top mipmap.</param> /// <param name="surfaceformat">Format header represents.</param> public DDS_Header(int Mips, int Height, int Width, ImageEngineFormat surfaceformat, DXGI_FORMAT dx10Format = DXGI_FORMAT.DXGI_FORMAT_UNKNOWN) { dwSize = 124; dwFlags = DDSdwFlags.DDSD_CAPS | DDSdwFlags.DDSD_HEIGHT | DDSdwFlags.DDSD_WIDTH | DDSdwFlags.DDSD_PIXELFORMAT | (Mips != 1 ? DDSdwFlags.DDSD_MIPMAPCOUNT : 0); this.Width = Width; this.Height = Height; dwCaps = DDSdwCaps.DDSCAPS_TEXTURE | (Mips == 1 ? 0 : DDSdwCaps.DDSCAPS_COMPLEX | DDSdwCaps.DDSCAPS_MIPMAP); dwMipMapCount = Mips == 1 ? 1 : Mips; ddspf = new DDS_PIXELFORMAT(surfaceformat); if (surfaceformat == ImageEngineFormat.DDS_DX10) { DX10_DXGI_AdditionalHeader = new DDS_DXGI_DX10_Additional { dxgiFormat = dx10Format, resourceDimension = D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE2D, miscFlag = DDS_DXGI_DX10_Additional.D3D10_RESOURCE_MISC_FLAGS.D3D10_RESOURCE_MISC_GENERATE_MIPS, miscFlags2 = DXGI_MiscFlags.DDS_ALPHA_MODE_UNKNOWN, arraySize = 1 } } ; }
public HRESULT Initialize1D(DXGI_FORMAT fmt, int length, int arraySize, int mipLevels) { return Utilities.HandleHRESULT(dxtInitialize1D(ptr, fmt, length, arraySize, mipLevels)); }
public static TextureDescription CreateTgaTexture(Memory <byte> tgaData, LoaderFlags loaderFlags = LoaderFlags.None) { if (tgaData.Length < sizeof(TGAHeader)) { ThrowHelper.ThrowInvalidDataException("Too small"); } Span <byte> span = tgaData.Span; TGAHeader header = MemoryMarshal.Read <TGAHeader>(span); if (IsCompressed(header.DataTypeCode)) { ThrowHelper.ThrowNotSupportedException("Compressed TGA textures are TODO"); // TODO } int size = header.Height * header.Width * (header.BitsPerPixel / 8); var data = new byte[size]; var buff = data; DXGI_FORMAT format = loaderFlags.HasFlag(LoaderFlags.ForceSrgb) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM; switch (header.BitsPerPixel) { case 24: RbgToRgba(span.Slice(sizeof(TGAHeader)), buff); break; case 32: ArbgToRgba(span.Slice(sizeof(TGAHeader)), buff); break; case 16: Rgba16ToRgba(span.Slice(sizeof(TGAHeader)), buff); break; default: ThrowHelper.ThrowNotSupportedException("Unsupported format"); break; } var subresources = new ManagedSubresourceData[1]; subresources[0] = new ManagedSubresourceData(); return(new TextureDescription( data, D3D12_RESOURCE_DIMENSION.D3D12_RESOURCE_DIMENSION_TEXTURE2D, new Size3((uint)header.Height, (uint)header.Width, 0), 1, 1, format, loaderFlags, false, subresources, header.BitsPerPixel == 24 ? AlphaMode.Opaque : AlphaMode.Unknown, TexType.Tga )); }
public bool OverrideFormat(TexMetadata mdata, DXGI_FORMAT f) { return dxtOverrideFormat(ptr, f); }
public int CheckOverlaySupport(DXGI_FORMAT EnumFormat, [NativeTypeName("IUnknown *")] IUnknown *pConcernedDevice, [NativeTypeName("UINT *")] uint *pFlags) { return(((delegate * unmanaged <IDXGIOutput6 *, DXGI_FORMAT, IUnknown *, uint *, int>)(lpVtbl[24]))((IDXGIOutput6 *)Unsafe.AsPointer(ref this), EnumFormat, pConcernedDevice, pFlags)); }
public DxtImage(int width, int height, DXGI_FORMAT format, int rowPitch, int slicePitch, IntPtr pixels) { this.width = (IntPtr)width; this.height = (IntPtr)height; this.format = format; this.rowPitch = (IntPtr)rowPitch; this.slicePitch = (IntPtr)slicePitch; this.pixels = pixels; }
public int GetDisplayModeList(DXGI_FORMAT EnumFormat, [NativeTypeName("UINT")] uint Flags, [NativeTypeName("UINT *")] uint *pNumModes, [NativeTypeName("DXGI_MODE_DESC *")] DXGI_MODE_DESC *pDesc) { return(((delegate * unmanaged <IDXGIOutput6 *, DXGI_FORMAT, uint, uint *, DXGI_MODE_DESC *, int>)(lpVtbl[8]))((IDXGIOutput6 *)Unsafe.AsPointer(ref this), EnumFormat, Flags, pNumModes, pDesc)); }
private extern static bool dxtIsCompressed(DXGI_FORMAT fmt);
public HRESULT ResizeBuffers(uint BufferCount, uint Width, uint Height, DXGI_FORMAT NewFormat, uint SwapChainFlags) { return(((delegate * unmanaged <IDXGISwapChain1 *, uint, uint, uint, DXGI_FORMAT, uint, int>)(lpVtbl[13]))((IDXGISwapChain1 *)Unsafe.AsPointer(ref this), BufferCount, Width, Height, NewFormat, SwapChainFlags)); }
private extern static uint dxtConvertArray(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, IntPtr cImages);
public D3D12_CLEAR_VALUE(DXGI_FORMAT format, float depth, [NativeTypeName("UINT8")] byte stencil) { Format = format; Anonymous.DepthStencil.Depth = depth; Anonymous.DepthStencil.Stencil = stencil; }
private extern static uint dxtCompressArray(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, IntPtr cImages);
public HRESULT CreateSurface(uint width, uint height, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, IDCompositionSurface **surface) { return(((delegate * unmanaged <IDCompositionDevice *, uint, uint, DXGI_FORMAT, DXGI_ALPHA_MODE, IDCompositionSurface **, int>)(lpVtbl[8]))((IDCompositionDevice *)Unsafe.AsPointer(ref this), width, height, pixelFormat, alphaMode, surface)); }
private extern static uint dxtDecompressArray(DxtImage[] cImages, int nimages, ref TexMetadata metadata, DXGI_FORMAT format, IntPtr images);
public HRESULT CreateVirtualSurface(uint initialWidth, uint initialHeight, DXGI_FORMAT pixelFormat, DXGI_ALPHA_MODE alphaMode, IDCompositionVirtualSurface **virtualSurface) { return(((delegate * unmanaged <IDCompositionDevice *, uint, uint, DXGI_FORMAT, DXGI_ALPHA_MODE, IDCompositionVirtualSurface **, int>)(lpVtbl[9]))((IDCompositionDevice *)Unsafe.AsPointer(ref this), initialWidth, initialHeight, pixelFormat, alphaMode, virtualSurface)); }
public static void ComputePitch(DXGI_FORMAT fmt, int width, int height, out int rowPitch, out int slicePitch, CP_FLAGS flags) { dxtComputePitch(fmt, width, height, out rowPitch, out slicePitch, flags); }
public HRESULT CreateSurfacePresenter(IUnknown *pDevice, uint width, uint height, uint backBufferCount, DXGI_FORMAT format, VIEW_OBJECT_ALPHA_MODE mode, ISurfacePresenter **ppQueue) { return(((delegate * unmanaged <IViewObjectPresentSite *, IUnknown *, uint, uint, uint, DXGI_FORMAT, VIEW_OBJECT_ALPHA_MODE, ISurfacePresenter **, int>)(lpVtbl[3]))((IViewObjectPresentSite *)Unsafe.AsPointer(ref this), pDevice, width, height, backBufferCount, format, mode, ppQueue)); }
public static HRESULT Convert(ref DxtImage srcImage, DXGI_FORMAT format, TEX_FILTER_FLAGS filter, float threshold, ScratchImage cImage) { return HandleHRESULT(dxtConvert(ref srcImage, format, filter, threshold, cImage.ptr)); }
public int CheckFormatSupport(DXGI_FORMAT Format, [NativeTypeName("UINT *")] uint *pFormatSupport) { return(((delegate * stdcall <ID3D11Device3 *, DXGI_FORMAT, uint *, int>)(lpVtbl[29]))((ID3D11Device3 *)Unsafe.AsPointer(ref this), Format, pFormatSupport)); }
public static HRESULT Compress(ref DxtImage srcImage, DXGI_FORMAT format, TEX_COMPRESS_FLAGS compress, float alphaRef, ScratchImage cImage) { return HandleHRESULT(dxtCompress(ref srcImage, format, compress, alphaRef, cImage.ptr)); }
public int CheckMultisampleQualityLevels1(DXGI_FORMAT Format, [NativeTypeName("UINT")] uint SampleCount, [NativeTypeName("UINT")] uint Flags, [NativeTypeName("UINT *")] uint *pNumQualityLevels) { return(((delegate * stdcall <ID3D11Device3 *, DXGI_FORMAT, uint, uint, uint *, int>)(lpVtbl[53]))((ID3D11Device3 *)Unsafe.AsPointer(ref this), Format, SampleCount, Flags, pNumQualityLevels)); }
public static HRESULT Decompress(ref DxtImage cImage, DXGI_FORMAT format, ScratchImage image) { return HandleHRESULT(dxtDecompress(ref cImage, format, image.ptr)); }
public static unsafe byte[] Convert(Byte[] data, int width, int height, DXGI_FORMAT inputFormat, DXGI_FORMAT outputFormat) { long inputRowPitch; long inputSlicePitch; TexHelper.Instance.ComputePitch(inputFormat, width, height, out inputRowPitch, out inputSlicePitch, CP_FLAGS.NONE); if (data.Length == inputSlicePitch) { byte *buf; buf = (byte *)Marshal.AllocHGlobal((int)inputSlicePitch); Marshal.Copy(data, 0, (IntPtr)buf, (int)inputSlicePitch); DirectXTexNet.Image inputImage = new DirectXTexNet.Image( width, height, inputFormat, inputRowPitch, inputSlicePitch, (IntPtr)buf, null); TexMetadata texMetadata = new TexMetadata(width, height, 1, 1, 1, 0, 0, inputFormat, TEX_DIMENSION.TEXTURE2D); ScratchImage scratchImage = TexHelper.Instance.InitializeTemporary( new DirectXTexNet.Image[] { inputImage }, texMetadata, null); var convFlags = TEX_FILTER_FLAGS.DEFAULT; if (inputFormat == DXGI_FORMAT.B8G8R8A8_UNORM_SRGB || inputFormat == DXGI_FORMAT.B8G8R8X8_UNORM_SRGB || inputFormat == DXGI_FORMAT.R8G8B8A8_UNORM_SRGB) { convFlags |= TEX_FILTER_FLAGS.SRGB; } using (var decomp = scratchImage.Convert(0, outputFormat, convFlags, 0.5f)) { long outRowPitch; long outSlicePitch; TexHelper.Instance.ComputePitch(outputFormat, width, height, out outRowPitch, out outSlicePitch, CP_FLAGS.NONE); byte[] result = new byte[outSlicePitch]; Marshal.Copy(decomp.GetImage(0).Pixels, result, 0, result.Length); inputImage = null; scratchImage.Dispose(); return(result); } } return(null); }
public static HRESULT ComputeNormalMap(DxtImage[] srcImages, int nimages, ref TexMetadata metadata, CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format, ScratchImage normalMaps) { return HandleHRESULT(dxtComputeNormalMap(srcImages, nimages, ref metadata, flags, amplitude, format, normalMaps.ptr)); }
public void ResolveSubresource(ID3D12Resource *pDstResource, [NativeTypeName("UINT")] uint DstSubresource, ID3D12Resource *pSrcResource, [NativeTypeName("UINT")] uint SrcSubresource, DXGI_FORMAT Format) { ((delegate * unmanaged <ID3D12GraphicsCommandList *, ID3D12Resource *, uint, ID3D12Resource *, uint, DXGI_FORMAT, void>)(lpVtbl[19]))((ID3D12GraphicsCommandList *)Unsafe.AsPointer(ref this), pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format); }
private extern static uint dxtInitialize2D(IntPtr img, DXGI_FORMAT fmt, int width, int height, int arraySize, int mipLevels);
public HRESULT GetDisplayModeList1(DXGI_FORMAT EnumFormat, uint Flags, uint *pNumModes, DXGI_MODE_DESC1 *pDesc) { return(((delegate * unmanaged <IDXGIOutput6 *, DXGI_FORMAT, uint, uint *, DXGI_MODE_DESC1 *, int>)(lpVtbl[19]))((IDXGIOutput6 *)Unsafe.AsPointer(ref this), EnumFormat, Flags, pNumModes, pDesc)); }
private extern static bool dxtOverrideFormat(IntPtr img, DXGI_FORMAT f);
public HRESULT CheckOverlaySupport(DXGI_FORMAT EnumFormat, IUnknown *pConcernedDevice, uint *pFlags) { return(((delegate * unmanaged <IDXGIOutput6 *, DXGI_FORMAT, IUnknown *, uint *, int>)(lpVtbl[24]))((IDXGIOutput6 *)Unsafe.AsPointer(ref this), EnumFormat, pConcernedDevice, pFlags)); }
public HRESULT Initialize2D(DXGI_FORMAT fmt, int width, int height, int arraySize, int mipLevels) { return Utilities.HandleHRESULT(dxtInitialize2D(ptr, fmt, width, height, arraySize, mipLevels)); }
public HRESULT CheckOverlayColorSpaceSupport(DXGI_FORMAT Format, DXGI_COLOR_SPACE_TYPE ColorSpace, IUnknown *pConcernedDevice, uint *pFlags) { return(((delegate * unmanaged <IDXGIOutput6 *, DXGI_FORMAT, DXGI_COLOR_SPACE_TYPE, IUnknown *, uint *, int>)(lpVtbl[25]))((IDXGIOutput6 *)Unsafe.AsPointer(ref this), Format, ColorSpace, pConcernedDevice, pFlags)); }
public HRESULT InitializeCube(DXGI_FORMAT fmt, int width, int height, int nCubes, int mipLevels) { return Utilities.HandleHRESULT(dxtInitializeCube(ptr, fmt, width, height, nCubes, mipLevels)); }
public TexMetadata(int width, int height, int depth, int arraySize, int mipLevels, TEX_MISC_FLAG miscFlags, int miscFlags2, DXGI_FORMAT format, TEX_DIMENSION dimension) { this.width = (IntPtr)width; this.height = (IntPtr)height; this.depth = (IntPtr)depth; this.arraySize = (IntPtr)arraySize; this.mipLevels = (IntPtr)mipLevels; this.miscFlags = miscFlags; this.miscFlags2 = miscFlags2; this.format = format; this.dimension = dimension; }
private static void ChangeDxtImageType(DxtTextureLibraryData libraryData, DXGI_FORMAT dxgiFormat) { if(((PixelFormat)libraryData.Metadata.format).SizeInBits() != ((PixelFormat)dxgiFormat).SizeInBits()) throw new ArgumentException("Impossible to change image data format. The two formats '{0}' and '{1}' are not compatibles.".ToFormat(libraryData.Metadata.format, dxgiFormat)); libraryData.Metadata.format = dxgiFormat; for (var i = 0; i < libraryData.DxtImages.Length; ++i) libraryData.DxtImages[i].format = dxgiFormat; }
public int CheckMultisampleQualityLevels(DXGI_FORMAT Format, [NativeTypeName("UINT")] uint SampleCount, [NativeTypeName("UINT *")] uint *pNumQualityLevels) { return(((delegate * unmanaged <ID3D10Device1 *, DXGI_FORMAT, uint, uint *, int>)(lpVtbl[91]))((ID3D10Device1 *)Unsafe.AsPointer(ref this), Format, SampleCount, pNumQualityLevels)); }