void CreateFontsTexture() { var io = ImGui.GetIO(); byte *pixels; int width, height; io.Fonts.GetTexDataAsRGBA32(out pixels, out width, out height); var texDesc = new Texture2DDescription { Width = width, Height = height, MipLevels = 1, ArraySize = 1, Format = Format.R8G8B8A8_UNorm, SampleDescription = new SampleDescription { Count = 1 }, Usage = Vortice.Direct3D11.Usage.Default, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None }; var subResource = new SubresourceData { DataPointer = (IntPtr)pixels, Pitch = texDesc.Width * 4, SlicePitch = 0 }; var texture = device.CreateTexture2D(texDesc, new[] { subResource }); var resViewDesc = new ShaderResourceViewDescription { Format = Format.R8G8B8A8_UNorm, ViewDimension = ShaderResourceViewDimension.Texture2D, Texture2D = new Texture2DShaderResourceView { MipLevels = texDesc.MipLevels, MostDetailedMip = 0 } }; fontTextureView = device.CreateShaderResourceView(texture, resViewDesc); texture.Release(); io.Fonts.TexID = RegisterTexture(fontTextureView); var samplerDesc = new SamplerDescription { Filter = Filter.MinMagMipLinear, AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, AddressW = TextureAddressMode.Wrap, MipLODBias = 0f, ComparisonFunction = ComparisonFunction.Always, MinLOD = 0f, MaxLOD = 0f }; fontSampler = device.CreateSamplerState(samplerDesc); }
public virtual bool Init(ID3D11Device device, ShaderInitParams InitParams) { // Attempt to construct pixel shader if (InitParams.PixelShaderFile.IsValid()) { Blob PixelBytecode = ConstructBytecode(InitParams.PixelShaderFile); OurPixelShader = device.CreatePixelShader(PixelBytecode); PixelBytecode.Dispose(); } // Attempt to construct vertex shader if (InitParams.VertexShaderFile.IsValid()) { Blob VertexBytecode = ConstructBytecode(InitParams.VertexShaderFile); OurVertexShader = device.CreateVertexShader(VertexBytecode); Layout = device.CreateInputLayout(InitParams.Elements, VertexBytecode); VertexBytecode.Dispose(); } // Attempt to construct geometry shader if (InitParams.GeometryShaderFile.IsValid()) { Blob GeometryBytecode = ConstructBytecode(InitParams.GeometryShaderFile); OurGeometryShader = device.CreateGeometryShader(GeometryBytecode); GeometryBytecode.Dispose(); } SamplerDescription samplerDesc = new SamplerDescription() { Filter = Filter.Anisotropic, AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, AddressW = TextureAddressMode.Wrap, MipLODBias = 0, MaxAnisotropy = 8, ComparisonFunction = ComparisonFunction.Always, BorderColor = new Color4(0, 0, 0, 0), MinLOD = 0, MaxLOD = 0 }; SamplerState = device.CreateSamplerState(samplerDesc); ConstantCameraBuffer = ConstantBufferFactory.ConstructBuffer <DCameraBuffer>(device, "CameraBuffer"); ConstantLightBuffer = ConstantBufferFactory.ConstructBuffer <LightBuffer>(device, "LightBuffer"); ConstantMatrixBuffer = ConstantBufferFactory.ConstructBuffer <MatrixBuffer>(device, "MatrixBuffer"); ConstantEditorParamsBuffer = ConstantBufferFactory.ConstructBuffer <EditorParameterBuffer>(device, "EditorBuffer"); return(true); }
public D3D11Sampler(ID3D11Device device, ref SamplerDescription description) { ComparisonFunction comparision = description.ComparisonKind == null ? ComparisonFunction.Never : D3D11Formats.VdToD3D11ComparisonFunc(description.ComparisonKind.Value); Vortice.Direct3D11.SamplerDescription samplerStateDesc = new Vortice.Direct3D11.SamplerDescription { AddressU = D3D11Formats.VdToD3D11AddressMode(description.AddressModeU), AddressV = D3D11Formats.VdToD3D11AddressMode(description.AddressModeV), AddressW = D3D11Formats.VdToD3D11AddressMode(description.AddressModeW), Filter = D3D11Formats.ToD3D11Filter(description.Filter, description.ComparisonKind.HasValue), MinLOD = description.MinimumLod, MaxLOD = description.MaximumLod, MaxAnisotropy = (int)description.MaximumAnisotropy, ComparisonFunction = comparision, MipLODBias = description.LodBias, BorderColor = ToRawColor4(description.BorderColor) }; DeviceSampler = device.CreateSamplerState(samplerStateDesc); }
public virtual void Shutdown() { ConstantLightBuffer?.Dispose(); ConstantLightBuffer = null; ConstantCameraBuffer?.Dispose(); ConstantCameraBuffer = null; ConstantMatrixBuffer?.Dispose(); ConstantMatrixBuffer = null; ConstantEditorParamsBuffer?.Dispose(); ConstantEditorParamsBuffer = null; SamplerState?.Dispose(); SamplerState = null; Layout?.Dispose(); Layout = null; OurPixelShader?.Dispose(); OurPixelShader = null; OurVertexShader?.Dispose(); OurVertexShader = null; OurGeometryShader?.Dispose(); OurGeometryShader = null; }
internal D3D11SamplerState(ID3D11SamplerState samplerState) { this.samplerState = samplerState; }
public unsafe void CSSetSampler(int startSlot, ID3D11SamplerState sampler) { var samplerPtr = sampler.NativePointer; CSSetSamplers(startSlot, 1, new IntPtr(&samplerPtr)); }
public Sampler(ID3D11SamplerState sampler) { _sampler = sampler; }