internal SdkMeshIndexBuffer(D3D11Device device, SdkMeshRawFile rawFile, SdkMeshRawMesh rawMesh)
        {
            int index = rawMesh.IndexBuffer;
            SdkMeshRawIndexBufferHeader header = rawFile.IndexBufferHeaders[index];

            byte[] bytes = rawFile.IndexBufferBytes[index];

            this.NumIndices = (int)header.NumIndices;
            this.SizeBytes  = (uint)header.SizeBytes;

            switch (header.IndexType)
            {
            case SdkMeshIndexType.IndexType16Bit:
                this.IndexFormat = DxgiFormat.R16UInt;
                break;

            case SdkMeshIndexType.IndexType32Bit:
                this.IndexFormat = DxgiFormat.R32UInt;
                break;

            default:
                this.IndexFormat = DxgiFormat.R16UInt;
                break;
            }

            var desc = new D3D11BufferDesc((uint)header.SizeBytes, D3D11BindOptions.IndexBuffer);
            var data = new D3D11SubResourceData(bytes, 0, 0);

            this.Buffer = device.CreateBuffer(desc, data);
        }
Ejemplo n.º 2
0
        static D3D11Buffer CreateRawBuffer <T>(D3D11Device pDevice, T[] pInitData)
            where T : struct
        {
            var desc = D3D11BufferDesc.From(pInitData, D3D11BindOptions.UnorderedAccess | D3D11BindOptions.ShaderResource | D3D11BindOptions.IndexBuffer | D3D11BindOptions.VertexBuffer);

            desc.MiscOptions = D3D11ResourceMiscOptions.BufferAllowRawViews;

            return(pDevice.CreateBuffer(desc, pInitData, 0, 0));
        }
Ejemplo n.º 3
0
        static D3D11Buffer CreateStructuredBuffer <T>(D3D11Device pDevice, T[] pInitData)
            where T : struct
        {
            var desc = D3D11BufferDesc.From(pInitData, D3D11BindOptions.UnorderedAccess | D3D11BindOptions.ShaderResource);

            desc.MiscOptions         = D3D11ResourceMiscOptions.BufferStructured;
            desc.StructureByteStride = (uint)Marshal.SizeOf(typeof(T));

            return(pDevice.CreateBuffer(desc, pInitData, 0, 0));
        }
        internal SdkMeshVertexBuffer(D3D11Device device, SdkMeshRawFile rawFile, SdkMeshRawMesh rawMesh, int i)
        {
            int index = rawMesh.VertexBuffers[i];
            SdkMeshRawVertexBufferHeader header = rawFile.VertexBufferHeaders[index];

            byte[] bytes = rawFile.VertexBufferBytes[index];

            this.NumVertices = (int)header.NumVertices;
            this.SizeBytes   = (uint)header.SizeBytes;
            this.StrideBytes = (uint)header.StrideBytes;
            this.Decl        = header.Decl.ToArray();

            var desc = new D3D11BufferDesc((uint)header.SizeBytes, D3D11BindOptions.VertexBuffer);
            var data = new D3D11SubResourceData(bytes, 0, 0);

            this.Buffer = device.CreateBuffer(desc, data);
        }
Ejemplo n.º 5
0
        static D3D11Buffer CreateAndCopyToDebugBuf(D3D11Device pDevice, D3D11DeviceContext pd3dImmediateContext, D3D11Buffer pBuffer)
        {
            var desc = pBuffer.Description;

            desc.CpuAccessOptions = D3D11CpuAccessOptions.Read;
            desc.Usage            = D3D11Usage.Staging;
            desc.BindOptions      = D3D11BindOptions.None;
            desc.MiscOptions      = D3D11ResourceMiscOptions.None;

            D3D11Buffer debugbuf = pDevice.CreateBuffer(desc);

#if DEBUG
            debugbuf.SetDebugName("Debug");
#endif

            pd3dImmediateContext.CopyResource(debugbuf, pBuffer);

            return(debugbuf);
        }