예제 #1
0
        /// <summary>
        /// Function to set up common states for a draw call type.
        /// </summary>
        /// <typeparam name="TB">The type of draw call builder.</typeparam>
        /// <typeparam name="TD">The type of draw call to return.</typeparam>
        /// <param name="builder">The builder to pass in.</param>
        /// <param name="renderable">The renderable being rendered.</param>
        /// <param name="batchState">The current batch level state.</param>
        /// <param name="renderer">The renderer used to send renderable data to the GPU.</param>
        private void SetCommonStates <TB, TD>(GorgonDrawCallBuilderCommon <TB, TD> builder, BatchRenderable renderable, Gorgon2DBatchState batchState, ObjectRenderer renderer)
            where TB : GorgonDrawCallBuilderCommon <TB, TD>
            where TD : GorgonDrawCallCommon
        {
            // If we haven't specified values for our first texture and sampler, then do so now.
            batchState.PixelShaderState.RwSrvs[0]     = renderable.Texture ?? _defaultTexture;
            batchState.PixelShaderState.RwSamplers[0] = renderable.TextureSampler ?? GorgonSamplerState.Default;

            builder.ConstantBuffers(ShaderType.Vertex, batchState.VertexShaderState.RwConstantBuffers)
            .ConstantBuffers(ShaderType.Pixel, batchState.PixelShaderState.RwConstantBuffers)
            .ShaderResources(ShaderType.Vertex, batchState.VertexShaderState.RwSrvs)
            .ShaderResources(ShaderType.Pixel, batchState.PixelShaderState.RwSrvs)
            .SamplerStates(ShaderType.Vertex, batchState.VertexShaderState.RwSamplers)
            .SamplerStates(ShaderType.Pixel, batchState.PixelShaderState.RwSamplers)
            .PipelineState(_stateBuilder.PixelShader(batchState.PixelShaderState.Shader)
                           .VertexShader(batchState.VertexShaderState.Shader)
                           .DepthStencilState(batchState.DepthStencilState)
                           .RasterState(batchState.RasterState)
                           .BlendState(batchState.BlendState)
                           .PrimitiveType(renderable.PrimitiveType));

            // If we don't supply a renderer type, then don't assign a vertex buffer.
            if (renderer == null)
            {
                return;
            }

            builder.VertexBuffer(_inputLayout, renderer.VertexBuffer);
        }
예제 #2
0
 /// <summary>
 /// Function to retrieve a draw indexed call from the pool and,  initialize it.
 /// </summary>
 /// <param name="renderable">The renderable to evaluate.</param>
 /// <param name="batchState">The current global state for the batch.</param>
 /// <param name="renderer">The renderer that will be </param>
 /// <returns>The draw call.</returns>
 public GorgonDrawIndexCall GetDrawIndexCall(BatchRenderable renderable, Gorgon2DBatchState batchState, ObjectRenderer renderer)
 {
     SetCommonStates(_drawIndexBuilder, renderable, batchState, renderer);
     return(_drawIndexBuilder.IndexBuffer(renderer.IndexBuffer)
            .Build(_drawIndexAllocator));
 }