/// <summary>
 /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 public D3D11RenderTargetViewDesc(
     D3D11RtvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice)
     : this(viewDimension, format, mipSlice, 0, uint.MaxValue)
 {
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mostDetailedMip">Index of the most detailed mipmap level to use.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11SrvDimension viewDimension,
     DxgiFormat format,
     uint mostDetailedMip)
     : this(viewDimension, format, mostDetailedMip, uint.MaxValue, 0, uint.MaxValue, D3D11BufferExSrvOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11DepthStencilViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The depth-stencil type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 public D3D11DepthStencilViewDesc(
     D3D11DsvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice)
     : this(viewDimension, format, mipSlice, 0, uint.MaxValue, D3D11DepthStencilViewOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11RenderTargetViewDesc(
     D3D11Texture2D texture,
     D3D11RtvDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, 0, uint.MaxValue)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
        /// </summary>
        /// <param name="buffer">A buffer.</param>
        /// <param name="format">The viewing format.</param>
        /// <param name="firstElement">The buffer and the first element to access.</param>
        /// <param name="numElements">The total number of elements in the view.</param>
        public D3D11RenderTargetViewDesc(
            D3D11Buffer buffer,
            DxgiFormat format,
            uint firstElement,
            uint numElements)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            this.buffer           = new D3D11BufferRtv();
            this.texture1D        = new D3D11Texture1DRtv();
            this.texture1DArray   = new D3D11Texture1DArrayRtv();
            this.texture2D        = new D3D11Texture2DRtv();
            this.texture2DArray   = new D3D11Texture2DArrayRtv();
            this.texture2DMs      = new D3D11Texture2DMsRtv();
            this.texture2DMsArray = new D3D11Texture2DMsArrayRtv();
            this.texture3D        = new D3D11Texture3DRtv();

            this.format        = format;
            this.viewDimension = D3D11RtvDimension.Buffer;
            this.buffer        = new D3D11BufferRtv
            {
                FirstElement = firstElement,
                NumElements  = numElements
            };
        }
Esempio n. 6
0
        public static DdsPixelFormat DxgiToDdsPixelFormat(DxgiFormat dxgiFormat)
        {
            DdsPixelFormat pixelFormat;

            switch (dxgiFormat)
            {
            case DxgiFormat.Bc1Unorm:
            case DxgiFormat.Bc1UnormSrgb:
                pixelFormat = DdsPfDxt1();
                break;

            case DxgiFormat.Bc2Unorm:
                pixelFormat = DdsPfDxt3();
                break;

            case DxgiFormat.Bc3Unorm:
                pixelFormat = DdsPfDxt5();
                break;

            case DxgiFormat.Bc4Unorm:
                pixelFormat = DdsPfAti1();
                break;

            case DxgiFormat.Bc5Unorm:
                pixelFormat = DdsPfAti2();
                break;

            default:
                pixelFormat = DdsPfDx10();
                break;
            }

            return(pixelFormat);
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
        /// </summary>
        /// <param name="buffer">A buffer.</param>
        /// <param name="format">The viewing format.</param>
        /// <param name="firstElement">The number of bytes between the beginning of the buffer and the first element to access.</param>
        /// <param name="numElements">The total number of elements in the view.</param>
        /// <param name="options">The view options for a buffer.</param>
        public D3D11ShaderResourceViewDesc(
            D3D11Buffer buffer,
            DxgiFormat format,
            uint firstElement,
            uint numElements,
            D3D11BufferExSrvOptions options)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            this.buffer           = new D3D11BufferSrv();
            this.texture1D        = new D3D11Texture1DSrv();
            this.texture1DArray   = new D3D11Texture1DArraySrv();
            this.texture2D        = new D3D11Texture2DSrv();
            this.texture2DArray   = new D3D11Texture2DArraySrv();
            this.texture2DMs      = new D3D11Texture2DMsSrv();
            this.texture2DMsArray = new D3D11Texture2DMsArraySrv();
            this.texture3D        = new D3D11Texture3DSrv();
            this.textureCube      = new D3D11TextureCubeSrv();
            this.textureCubeArray = new D3D11TextureCubeArraySrv();
            this.bufferEx         = new D3D11BufferExSrv();

            this.format        = format;
            this.viewDimension = D3D11SrvDimension.BufferEx;
            this.bufferEx      = new D3D11BufferExSrv
            {
                FirstElement = firstElement,
                NumElements  = numElements,
                Options      = options
            };
        }
Esempio n. 8
0
        public static bool IsBlockCompressedFormat(DxgiFormat format)
        {
            switch (format)
            {
            case DxgiFormat.BC1_Typeless:
            case DxgiFormat.BC1_UNorm:
            case DxgiFormat.BC1_UNorm_SRGB:
            case DxgiFormat.BC2_Typeless:
            case DxgiFormat.BC2_UNorm:
            case DxgiFormat.BC2_UNorm_SRGB:
            case DxgiFormat.BC3_Typeless:
            case DxgiFormat.BC3_UNorm:
            case DxgiFormat.BC3_UNorm_SRGB:
            case DxgiFormat.BC4_Typeless:
            case DxgiFormat.BC4_UNorm:
            case DxgiFormat.BC4_SNorm:
            case DxgiFormat.BC5_Typeless:
            case DxgiFormat.BC5_UNorm:
            case DxgiFormat.BC5_SNorm:
            case DxgiFormat.BC6H_Typeless:
            case DxgiFormat.BC6H_SF16:
            case DxgiFormat.BC6H_UF16:
            case DxgiFormat.BC7_Typeless:
            case DxgiFormat.BC7_UNorm:
            case DxgiFormat.BC7_UNorm_SRGB:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 9
0
        public static bool IsPackedFormat(DxgiFormat format)
        {
            switch (format)
            {
            case DxgiFormat.YUY2:
            case DxgiFormat.Y210:
            case DxgiFormat.Y216:
            case DxgiFormat.Y410:
            case DxgiFormat.Y416:
            case DxgiFormat.Opaque_420:
            case DxgiFormat.AI44:
            case DxgiFormat.AYUV:
            case DxgiFormat.IA44:
            case DxgiFormat.NV11:
            case DxgiFormat.NV12:
            case DxgiFormat.P010:
            case DxgiFormat.P016:
            case DxgiFormat.R8G8_B8G8_UNorm:
            case DxgiFormat.G8R8_G8B8_UNorm:
                return(true);

            default:
                return(false);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11UavDimension viewDimension,
     DxgiFormat format,
     uint mipSlice)
     : this(viewDimension, format, mipSlice, 0, uint.MaxValue, D3D11BufferUavOptions.None)
 {
 }
Esempio n. 11
0
        private static int DxgiToFourCc(DxgiFormat dxgiFormat)
        {
            int fourCc;

            switch (dxgiFormat)
            {
            case DxgiFormat.Bc1Unorm:
            case DxgiFormat.Bc1UnormSrgb:
                fourCc = Dxt1FourCc;     // DXT1
                break;

            case DxgiFormat.Bc2Unorm:
                fourCc = Dxt3FourCc;     // DXT3
                break;

            case DxgiFormat.Bc3Unorm:
                fourCc = Dtx5FourCc;     // DXT5
                break;

            case DxgiFormat.Bc4Unorm:
                fourCc = Ati1FourCc;     // ATI1
                break;

            case DxgiFormat.Bc5Unorm:
                fourCc = Ati2FourCc;     // ATI2
                break;

            default:
                fourCc = Dx10FourCc;     // DX10
                break;
            }

            return(fourCc);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 3D texture.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 public D3D11RenderTargetViewDesc(
     D3D11Texture3D texture,
     DxgiFormat format,
     uint mipSlice)
     : this(texture, format, mipSlice, 0, uint.MaxValue)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 3D texture.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11Texture3D texture,
     DxgiFormat format,
     uint mipSlice)
     : this(texture, format, mipSlice, 0, uint.MaxValue)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
        /// </summary>
        /// <param name="buffer">A buffer.</param>
        /// <param name="format">The viewing format.</param>
        /// <param name="firstElement">The number of bytes between the beginning of the buffer and the first element to access.</param>
        /// <param name="numElements">The total number of elements in the view.</param>
        /// <param name="options">The view options for a buffer.</param>
        public D3D11UnorderedAccessViewDesc(
            D3D11Buffer buffer,
            DxgiFormat format,
            uint firstElement,
            uint numElements,
            D3D11BufferUavOptions options)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            this.buffer         = new D3D11BufferUav();
            this.texture1D      = new D3D11Texture1DUav();
            this.texture1DArray = new D3D11Texture1DArrayUav();
            this.texture2D      = new D3D11Texture2DUav();
            this.texture2DArray = new D3D11Texture2DArrayUav();
            this.texture3D      = new D3D11Texture3DUav();

            this.format        = format;
            this.viewDimension = D3D11UavDimension.Buffer;
            this.buffer        = new D3D11BufferUav
            {
                FirstElement = firstElement,
                NumElements  = numElements,
                Options      = options
            };
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11Texture2D texture,
     D3D11UavDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, 0, uint.MaxValue)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11DepthStencilViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The depth-stencil type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11DepthStencilViewDesc(
     D3D11Texture2D texture,
     D3D11DsvDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, 0, uint.MaxValue, D3D11DepthStencilViewOptions.None)
 {
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 3D texture.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mostDetailedMip">The index of the most detailed mipmap level to use.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11Texture3D texture,
     DxgiFormat format,
     uint mostDetailedMip)
     : this(texture, format, mostDetailedMip, uint.MaxValue)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11Texture2D texture,
     D3D11SrvDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, uint.MaxValue, 0, uint.MaxValue)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="buffer">A buffer.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="firstElement">The number of bytes between the beginning of the buffer and the first element to access.</param>
 /// <param name="numElements">The total number of elements in the view.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11Buffer buffer,
     DxgiFormat format,
     uint firstElement,
     uint numElements)
     : this(buffer, format, firstElement, numElements, D3D11BufferUavOptions.None)
 {
 }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 1D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mostDetailedMip">The index of the most detailed mipmap level to use.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11Texture1D texture,
     D3D11SrvDimension viewDimension,
     DxgiFormat format,
     uint mostDetailedMip)
     : this(texture, viewDimension, format, mostDetailedMip, uint.MaxValue, 0, uint.MaxValue)
 {
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="buffer">A buffer.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="firstElement">The number of bytes between the beginning of the buffer and the first element to access.</param>
 /// <param name="numElements">The total number of elements in the view.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11Buffer buffer,
     DxgiFormat format,
     uint firstElement,
     uint numElements)
     : this(buffer, format, firstElement, numElements, D3D11BufferExSrvOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
 /// <param name="arraySize">The number of elements in the array.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11UavDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firstArraySlice,
     uint arraySize)
     : this(viewDimension, format, mipSlice, firstArraySlice, arraySize, D3D11BufferUavOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11DepthStencilViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The depth-stencil type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
 public D3D11DepthStencilViewDesc(
     D3D11Texture2D texture,
     D3D11DsvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firstArraySlice)
     : this(texture, viewDimension, format, mipSlice, firstArraySlice, uint.MaxValue, D3D11DepthStencilViewOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11Texture2D texture,
     D3D11UavDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firstArraySlice)
     : this(texture, viewDimension, format, mipSlice, firstArraySlice, uint.MaxValue)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11DepthStencilViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The depth-stencil type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
 /// <param name="arraySize">The number of elements in the array.</param>
 public D3D11DepthStencilViewDesc(
     D3D11DsvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firstArraySlice,
     uint arraySize)
     : this(viewDimension, format, mipSlice, firstArraySlice, arraySize, D3D11DepthStencilViewOptions.None)
 {
 }
Esempio n. 26
0
        public static int GetBitsPerPixel(D3dFormat d3dFormat, DxgiFormat dxgiFormat)
        {
            if (dxgiFormat != DxgiFormat.Unknown)
            {
                return(GetBitsPerPixel(dxgiFormat));
            }

            return(GetBitsPerPixel(d3dFormat));
        }
Esempio n. 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mostDetailedMip">Index of the most detailed mipmap level to use.</param>
 /// <param name="mipLevels">The maximum number of mipmap levels for the view.</param>
 /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11SrvDimension viewDimension,
     DxgiFormat format,
     uint mostDetailedMip,
     uint mipLevels,
     uint firstArraySlice)
     : this(viewDimension, format, mostDetailedMip, mipLevels, firstArraySlice, uint.MaxValue, D3D11BufferExSrvOptions.None)
 {
 }
Esempio n. 28
0
 /// <summary>
 /// Creates a new instance of <see cref="DdsImage"/> with the specified dimensions and pixel data, using D3D10 header and format information.
 /// </summary>
 /// <param name="height">The height of the image in pixels.</param>
 /// <param name="width">The width of the image in pixels.</param>
 /// <param name="dxgiFormat">The DxgiFormat value that identifies the format of the pixel data.</param>
 /// <param name="textureType">The type of texture represented by the image.</param>
 /// <param name="pixelData">The binary data containing the pixels of the image.</param>
 public DdsImage(int height, int width, DxgiFormat dxgiFormat, byte[] pixelData)
     : this(height, width, FourCC.DX10, pixelData)
 {
     dx10Header.DxgiFormat        = dxgiFormat;
     dx10Header.ResourceDimension = D3D10ResourceDimension.Texture2D;
     dx10Header.MiscFlags         = D3D10ResourceMiscFlags.None;
     dx10Header.ArraySize         = 1;
     dx10Header.MiscFlags2        = D3D10ResourceMiscFlag2.DdsAlphaModeStraight;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
 /// <param name="firtArraySlice">The index of the first element to use in an array of elements.</param>
 public D3D11RenderTargetViewDesc(
     D3D11Texture2D texture,
     D3D11RtvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firtArraySlice)
     : this(texture, viewDimension, format, mipSlice, firtArraySlice, uint.MaxValue)
 {
 }
Esempio n. 30
0
        private void RenderMesh(int meshIndex, int diffuseSlot, int normalSlot, int specularSlot)
        {
            if (meshIndex < 0 || meshIndex >= this.Meshes.Count)
            {
                return;
            }

            SdkMeshMesh mesh = this.Meshes[meshIndex];

            if (mesh.VertexBuffers.Length > D3D11Constants.InputAssemblerVertexInputResourceSlotCount)
            {
                return;
            }

            D3D11Buffer[] vb      = new D3D11Buffer[mesh.VertexBuffers.Length];
            uint[]        strides = new uint[mesh.VertexBuffers.Length];
            uint[]        offsets = new uint[mesh.VertexBuffers.Length];

            for (int i = 0; i < mesh.VertexBuffers.Length; i++)
            {
                vb[i]      = mesh.VertexBuffers[i].Buffer;
                strides[i] = mesh.VertexBuffers[i].StrideBytes;
                offsets[i] = 0;
            }

            D3D11Buffer ib       = mesh.IndexBuffer.Buffer;
            DxgiFormat  ibFormat = mesh.IndexBuffer.IndexFormat;

            this._d3dDeviceContext.InputAssemblerSetVertexBuffers(0, vb, strides, offsets);
            this._d3dDeviceContext.InputAssemblerSetIndexBuffer(ib, ibFormat, 0);


            foreach (SdkMeshSubset subset in mesh.Subsets)
            {
                this._d3dDeviceContext.InputAssemblerSetPrimitiveTopology(subset.PrimitiveTopology);

                SdkMeshMaterial material = this.Materials[subset.MaterialIndex];

                if (diffuseSlot != -1 && material.DiffuseTextureView != null)
                {
                    this._d3dDeviceContext.PixelShaderSetShaderResources((uint)diffuseSlot, new[] { material.DiffuseTextureView });
                }

                if (normalSlot != -1 && material.NormalTextureView != null)
                {
                    this._d3dDeviceContext.PixelShaderSetShaderResources((uint)normalSlot, new[] { material.NormalTextureView });
                }

                if (specularSlot != -1 && material.SpecularTextureView != null)
                {
                    this._d3dDeviceContext.PixelShaderSetShaderResources((uint)specularSlot, new[] { material.SpecularTextureView });
                }

                this._d3dDeviceContext.DrawIndexed((uint)subset.IndexCount, (uint)subset.IndexStart, subset.VertexStart);
            }
        }
        public DxgiModeDesc[] GetDisplayModeList(DxgiFormat format, DxgiEnumModes modes)
        {
            uint numModes = 0;
            this.output.GetDisplayModeList(format, modes, ref numModes, null);

            DxgiModeDesc[] displayModes = new DxgiModeDesc[numModes];

            this.output.GetDisplayModeList(format, modes, ref numModes, displayModes);

            return displayModes;
        }
Esempio n. 32
0
        private void ReadDx10Header(Ibasa.IO.BinaryReader reader)
        {
            if (!IsDX10Mode)
                return;

            DxgiFormat = (DxgiFormat)reader.ReadInt32();
            ResourceDimension = (ResourceDimensionEnum)reader.ReadInt32();
            MiscFlags = (MiscFlagsEnum)reader.ReadInt32();
            ArraySize = reader.ReadInt32();
            reader.ReadBytes(4); //skip padding
        }
Esempio n. 33
0
        public DdsTexture(DxgiFormat dxgiFormat,
            int width, int height = 1, int depth = 1, 
            int arraySize = 1, int mipCount = 0,
            ResourceDimension dimension = ResourceDimension.Unknown, 
            ResourceMiscFlags miscFlags = 0
            )
        {
            if (dxgiFormat == DxgiFormat.UNKNOWN)
                throw new ArgumentException("Formats can not be 'unknown'");
            if (width <= 0)
                throw new ArgumentException("Width must be greater than zero");
            if (height <= 0)
                throw new ArgumentException("Height must be greater than zero");
            if (depth <= 0)
                throw new ArgumentException("Depth must be greater than zero");
            if (arraySize <= 0)
                throw new ArgumentException("Array size must be greater than zero");
            if (mipCount < 0)
                throw new ArgumentException("Mip count must can not be negative");
            if (dimension != ResourceDimension.Unknown && dimension != ResourceDimension.Texture3D && depth != 1)
                throw new ArgumentException(string.Format("Dimension10 is {0}, but Depth is not 1", dimension));
            if ((dimension == ResourceDimension.Buffer || dimension == ResourceDimension.Texture1D) && height != 1)
                throw new ArgumentException(string.Format("Dimension10 is {0}, but Height is not 1", dimension));
            if (dimension == ResourceDimension.Buffer && mipCount > 1)
                throw new ArgumentException("Dimension10 is Buffer, but MipCount is not 0 or 1");

            Width = width;
            Height = height;
            Depth = depth;
            /*
            if (depth != 1)
                Dimension10 = ResourceDimension.Texture3D;
            else if (height != 1)
                Dimension10 = ResourceDimension.Texture2D;
            else
                Dimension10 = ResourceDimension.Texture1D;*/

            MiscFlags10 = miscFlags;

            D3DFormat = Helper.D3DFormatFromDxgi(dxgiFormat);

            Data = new byte[arraySize][];

            if (mipCount == 0)
            {
                int mipWidth = width;
                int mipHeight = height;
                int mipDepth = depth;

                mipCount = 1;
                while (mipWidth != 1 || mipHeight != 1 || mipDepth != 1)
                {
                    if (mipWidth != 1) mipWidth /= 2;
                    if (mipHeight != 1) mipHeight /= 2;
                    if (mipDepth != 1) mipDepth /= 2;
                    mipCount++;
                }
            }

            int chainSize;
            CalculateMipInfos(mipCount, -1, -1, out chainSize);

            for (int i = 0; i < Data.Length; i++)
                Data[i] = new byte[chainSize];
        }
 public void ResizeBuffers(uint bufferCount, uint width, uint height, DxgiFormat format, DxgiSwapChainOptions options)
 {
     this.swapChain.ResizeBuffers(bufferCount, width, height, format, options);
 }