Esempio n. 1
0
 public override RasterizerState CreateRasterizerState(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     return(new D3DRasterizerState(_device, cullMode, fillMode, isDepthClipEnabled, isScissorTestEnabled));
 }
 protected override RasterizerState CreateRasterizerStateCore(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     return(new OpenGLRasterizerState(cullMode, fillMode, isDepthClipEnabled, isScissorTestEnabled));
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a new <see cref="RasterizerState"/>, used to control various behaviors of the device's rasterizer.
 /// </summary>
 /// <param name="cullMode">Controls which primitive faces are culled.</param>
 /// <param name="fillMode">The kind of triangle filling to use.</param>
 /// <param name="isDepthClipEnabled">Whether or not primitives are clipped by depth.</param>
 /// <param name="isScissorTestEnabled">Whether or not primitives are clipped by the scissor test.</param>
 /// <returns>A new <see cref="RasterizerState"/>.</returns>
 public RasterizerState CreateRasterizerState(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     return(CreateRasterizerStateCore(cullMode, fillMode, isDepthClipEnabled, isScissorTestEnabled));
 }
 public OpenGLESRasterizerState(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool depthClipEnabled,
     bool scissorTestEnabled)
 {
     CullMode             = cullMode;
     FillMode             = fillMode;
     IsDepthClipEnabled   = depthClipEnabled;
     IsScissorTestEnabled = scissorTestEnabled;
 }
 public RasterizerStateCacheKey(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     CullMode             = cullMode;
     FillMode             = fillMode;
     IsDepthClipEnabled   = isDepthClipEnabled;
     IsScissorTestEnabled = isScissorTestEnabled;
 }
 public RasterizerStateDescription(
     FaceCullMode cullMode,
     TriangleFillMode fillMode,
     FrontFace frontFace,
     bool depthClipEnabled,
     bool scissorTestEnabled)
 {
     CullMode           = cullMode;
     FillMode           = fillMode;
     FrontFace          = frontFace;
     DepthClipEnabled   = depthClipEnabled;
     ScissorTestEnabled = scissorTestEnabled;
 }
Esempio n. 7
0
        internal static VkPolygonMode VeldridToVkFillMode(TriangleFillMode fillMode)
        {
            switch (fillMode)
            {
            case TriangleFillMode.Solid:
                return(VkPolygonMode.Fill);

            case TriangleFillMode.Wireframe:
                return(VkPolygonMode.Line);

            default:
                throw Illegal.Value <TriangleFillMode>();
            }
        }
Esempio n. 8
0
        internal static FillMode VeldridToD3DTriangleFillMode(TriangleFillMode fillMode)
        {
            switch (fillMode)
            {
            case TriangleFillMode.Solid:
                return(FillMode.Solid);

            case TriangleFillMode.Wireframe:
                return(FillMode.Wireframe);

            default:
                throw Illegal.Value <TriangleFillMode>();
            }
        }
Esempio n. 9
0
        internal static PolygonMode ConvertFillMode(TriangleFillMode fillMode)
        {
            switch (fillMode)
            {
            case TriangleFillMode.Solid:
                return(PolygonMode.Fill);

            case TriangleFillMode.Wireframe:
                return(PolygonMode.Line);

            default:
                throw Illegal.Value <TriangleFillMode>();
            }
        }
Esempio n. 10
0
        public VkRasterizerState(FaceCullingMode cullMode, TriangleFillMode fillMode, bool isDepthClipEnabled, bool isScissorTestEnabled)
        {
            CullMode             = cullMode;
            FillMode             = fillMode;
            IsDepthClipEnabled   = isDepthClipEnabled;
            IsScissorTestEnabled = isScissorTestEnabled;

            VkPipelineRasterizationStateCreateInfo rasterizerStateCI = VkPipelineRasterizationStateCreateInfo.New();

            rasterizerStateCI.cullMode         = VkFormats.VeldridToVkCullMode(cullMode);
            rasterizerStateCI.polygonMode      = VkFormats.VeldridToVkFillMode(fillMode);
            rasterizerStateCI.depthClampEnable = !isDepthClipEnabled; // TODO: Same as OpenGL (?)
            rasterizerStateCI.frontFace        = VkFrontFace.Clockwise;

            RasterizerStateCreateInfo = rasterizerStateCI;
        }
Esempio n. 11
0
        public D3DRasterizerState(
            Device device,
            FaceCullingMode cullMode,
            TriangleFillMode fillMode,
            bool depthClipEnabled,
            bool scissorTestEnabled)
        {
            _device              = device;
            CullMode             = cullMode;
            FillMode             = fillMode;
            IsDepthClipEnabled   = depthClipEnabled;
            IsScissorTestEnabled = scissorTestEnabled;

            var desc = new RasterizerStateDescription()
            {
                IsDepthClipEnabled = IsDepthClipEnabled,
                IsScissorEnabled   = IsScissorTestEnabled,
                CullMode           = D3DFormats.ConvertCullMode(cullMode),
                FillMode           = D3DFormats.ConvertFillMode(fillMode)
            };

            _deviceState = new SharpDX.Direct3D11.RasterizerState(device, desc);
        }
Esempio n. 12
0
 /// <summary>
 /// Creates a new <see cref="RasterizerState"/>, used to control various behaviors of the device's rasterizer.
 /// </summary>
 /// <param name="cullMode">Controls which primitive faces are culled.</param>
 /// <param name="fillMode">The kind of triangle filling to use.</param>
 /// <param name="isDepthClipEnabled">Whether or not primitives are clipped by depth.</param>
 /// <param name="isScissorTestEnabled">Whether or not primitives are clipped by the scissor test.</param>
 /// <returns>A new <see cref="RasterizerState"/>.</returns>
 protected abstract RasterizerState CreateRasterizerStateCore(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled);
        public RenderStateDesc_NativeInterop(ref RenderStateDesc desc)
        {
            renderPass   = ((RenderPass)desc.renderPass).handle;
            shaderEffect = ((ShaderEffect)desc.shaderEffect).handle;

            if (desc.constantBuffers != null)
            {
                constantBufferCount = desc.constantBuffers.Length;
                constantBuffers     = (IntPtr *)Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>() * constantBufferCount);
                for (int i = 0; i != constantBufferCount; ++i)
                {
                    constantBuffers[i] = ((ConstantBuffer)desc.constantBuffers[i]).handle;
                }
            }
            else
            {
                constantBufferCount = 0;
                constantBuffers     = null;
            }

            if (desc.textures != null)
            {
                textureCount = desc.textures.Length;
                textures     = (IntPtr *)Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>() * textureCount);
                for (int i = 0; i != textureCount; ++i)
                {
                    textures[i] = desc.textures[i].GetHandle();
                }
            }
            else
            {
                textureCount = 0;
                textures     = null;
            }

            if (desc.textureDepthStencils != null)
            {
                textureDepthStencilCount = desc.textureDepthStencils.Length;
                textureDepthStencils     = (IntPtr *)Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>() * textureDepthStencilCount);
                for (int i = 0; i != textureDepthStencilCount; ++i)
                {
                    textureDepthStencils[i] = desc.textureDepthStencils[i].GetHandle();
                }
            }
            else
            {
                textureDepthStencilCount = 0;
                textureDepthStencils     = null;
            }

            if (desc.randomAccessBuffers != null)
            {
                randomAccessBufferCount = desc.randomAccessBuffers.Length;
                randomAccessBuffers     = (IntPtr *)Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>() * randomAccessBufferCount);
                randomAccessTypes       = (RandomAccessBufferType *)Marshal.AllocHGlobal(sizeof(RandomAccessBufferType) * randomAccessBufferCount);
                for (int i = 0; i != randomAccessBufferCount; ++i)
                {
                    var buffer = desc.randomAccessBuffers[i];
                    var type   = buffer.GetType();
                    if (typeof(Texture2DBase).IsAssignableFrom(type))
                    {
                        randomAccessBuffers[i] = ((Texture2DBase)buffer).GetHandle();
                        randomAccessTypes[i]   = RandomAccessBufferType.Texture;
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported ComputeShader random access buffer type: " + type.ToString());
                    }
                }
            }
            else
            {
                randomAccessBufferCount = 0;
                randomAccessBuffers     = null;
                randomAccessTypes       = null;
            }

            vertexBufferTopology = desc.vertexBufferTopology;
            vertexBufferStreamer = ((VertexBufferStreamer)desc.vertexBufferStreamer).handle;
            if (desc.indexBuffer != null)
            {
                indexBuffer = ((IndexBuffer)desc.indexBuffer).handle;
            }
            else
            {
                indexBuffer = IntPtr.Zero;
            }
            triangleCulling  = desc.triangleCulling;
            triangleFillMode = desc.triangleFillMode;
            blendDesc        = new BlendDesc_NativeInterop(ref desc.blendDesc);
            depthStencilDesc = new DepthStencilDesc_NativeInterop(ref desc.depthStencilDesc);
        }