Ejemplo n.º 1
0
        public Dx11PipelineState(Dx11RenderingDevice device, string shaderName, InputElement[] inputElements)
        {
            // Vertex shader
            using (Stream VertexShaderStream = ThisAssembly.GetManifestResourceStream("DxShaders." + shaderName + "VS"))
            {
                if (VertexShaderStream == null)
                {
                    throw new Exception("Vertex shader for \"" + shaderName + "\" not found.");
                }
                byte[] VertexShaderBytes = new byte[VertexShaderStream.Length];
                VertexShaderStream.Read(VertexShaderBytes, 0, VertexShaderBytes.Length);
                VertexShader = new VertexShader(device.Device, VertexShaderBytes);
                VertexShader.SetDebugName(shaderName);

                // Input layout
                InputLayout = new InputLayout(device.Device, VertexShaderBytes, inputElements);
                InputLayout.SetDebugName(shaderName);
            }

            // Pixel shader
            using (Stream PixelShaderStream = ThisAssembly.GetManifestResourceStream("DxShaders." + shaderName + "PS"))
            {
                if (PixelShaderStream == null)
                {
                    throw new Exception("Pixel shader for \"" + shaderName + "\" not found.");
                }
                byte[] PixelShaderBytes = new byte[PixelShaderStream.Length];
                PixelShaderStream.Read(PixelShaderBytes, 0, PixelShaderBytes.Length);
                PixelShader = new PixelShader(device.Device, PixelShaderBytes);
                PixelShader.SetDebugName(shaderName);
            }
        }