internal unsafe MyFoliageGeneratingPass()
        {
            var soElements = new StreamOutputElement[2];

            soElements[0].Stream         = 0;
            soElements[0].SemanticName   = "TEXCOORD";
            soElements[0].SemanticIndex  = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot     = 0;
            soElements[1].Stream         = 0;
            soElements[1].SemanticName   = "TEXCOORD";
            soElements[1].SemanticIndex  = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot     = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            if (m_geometryShader == GeometryShaderId.NULL)
            {
                string stageFile = Path.Combine(MyMaterialShaders.PassesFolder, MyMaterialShaders.FOLIAGE_STREAMING_PASS, "GeometryStage.hlsl");
                m_geometryShader = MyShaders.CreateGs(stageFile, null, new MyShaderStreamOutputInfo {
                    Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream
                });
            }

            SetImmediate(true);
        }
Exemplo n.º 2
0
        internal static GeometryShaderId CreateGs(string file, ShaderMacro[] macros = null, MyShaderStreamOutputInfo?streamOut = null)
        {
            var bytecode = CreateBytecode();

            var id = new GeometryShaderId {
                Index = GeometryShaders.Allocate()
            };

            GeometryShaders.Data[id.Index] = new MyShaderInfo
            {
                Bytecode = bytecode
            };
            MyArrayHelpers.Reserve(ref GsObjects, id.Index + 1);

            // compile at once

            Shaders[bytecode] = new MyShaderCompilationInfo
            {
                File    = X.TEXT_(file),
                Profile = MyShadersDefines.Profiles.gs_5_0,
                Macros  = macros
            };

            GsObjects[id.Index] = null;

            if (streamOut.HasValue)
            {
                StreamOutputs[id] = streamOut.Value;
            }

            InitGs(id);
            GsIndex.Add(id);

            return(id);
        }
        internal unsafe MyFoliageGeneratingPass()
        {
            var soElements = new StreamOutputElement[2];

            soElements[0].Stream         = 0;
            soElements[0].SemanticName   = "TEXCOORD";
            soElements[0].SemanticIndex  = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot     = 0;
            soElements[1].Stream         = 0;
            soElements[1].SemanticName   = "TEXCOORD";
            soElements[1].SemanticIndex  = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot     = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            if (m_geometryShader == GeometryShaderId.NULL)
            {
                m_geometryShader = MyShaders.CreateGs("passes/foliage_streaming/geometry_stage.hlsl", null, new MyShaderStreamOutputInfo {
                    Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream
                });
            }

            SetImmediate(true);
        }
Exemplo n.º 4
0
 internal static void Init()
 {
     m_VS          = MyShaders.CreateVs("foliage2.hlsl", "vs");
     m_GS          = MyShaders.CreateGs("foliage2.hlsl", "gs");
     m_PS          = MyShaders.CreatePs("foliage2.hlsl", "ps");
     m_inputLayout = MyShaders.CreateIL(m_VS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.CUSTOM_UNORM4_0));
 }
Exemplo n.º 5
0
        internal static void InitGs(GeometryShaderId id, string file)
        {
            var bytecodeId = GeometryShaders.Data[id.Index].Bytecode;

            Compile(bytecodeId);

            if (GsObjects[id.Index] != null)
            {
                GsObjects[id.Index].Dispose();
                GsObjects[id.Index] = null;
            }

            try
            {
                if (StreamOutputs.ContainsKey(id))
                {
                    var so = StreamOutputs[id];

                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId),
                                                             so.Elements, so.Strides, so.RasterizerStreams, null);
                }
                else
                {
                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId));
                }
            }
            catch (SharpDXException e)
            {
                Compile(bytecodeId, true);

                if (StreamOutputs.ContainsKey(id))
                {
                    var so = StreamOutputs[id];

                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId),
                                                             so.Elements, so.Strides, so.RasterizerStreams, null);
                }
                else
                {
                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId));
                }
            }
            GeometryShaders.Data[id.Index].File = file;
            GsObjects[id.Index].DebugName       = file;
        }
        internal unsafe MyFoliageGeneratingPass()
        {
            var soElements = new StreamOutputElement[2];
            soElements[0].Stream = 0;
            soElements[0].SemanticName = "TEXCOORD";
            soElements[0].SemanticIndex = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot = 0;
            soElements[1].Stream = 0;
            soElements[1].SemanticName = "TEXCOORD";
            soElements[1].SemanticIndex = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            if(m_geometryShader == GeometryShaderId.NULL)
                m_geometryShader = MyShaders.CreateGs("passes/foliage_streaming/geometry_stage.hlsl", null, new MyShaderStreamOutputInfo { Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream });

            SetImmediate(true);
        }
Exemplo n.º 7
0
        internal static unsafe void Init()
        {
            var soElements = new StreamOutputElement[2];

            soElements[0].Stream         = 0;
            soElements[0].SemanticName   = "TEXCOORD";
            soElements[0].SemanticIndex  = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot     = 0;
            soElements[1].Stream         = 0;
            soElements[1].SemanticName   = "TEXCOORD";
            soElements[1].SemanticIndex  = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot     = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            m_gs = MyShaders.CreateGs("passes/foliage_streaming/geometry_stage.hlsl", "gs", "", new MyShaderStreamOutputInfo {
                Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream
            });

            m_instance.SetImmediate(true);
        }
Exemplo n.º 8
0
        internal static GeometryShaderId CreateGs(string file, string func, string header = "", MyShaderStreamOutputInfo?streamOut = null)
        {
            var bytecode = CreateBytecode();

            var id = new GeometryShaderId {
                Index = GeometryShaders.Allocate()
            };

            GeometryShaders.Data[id.Index] = new MyShaderInfo
            {
                Bytecode = bytecode
            };
            MyArrayHelpers.Reserve(ref GsObjects, id.Index + 1);

            // compile at once

            Shaders[bytecode] = new MyShaderCompilationInfo
            {
                File     = X.TEXT(file),
                Function = X.TEXT(func),
                Profile  = MyShaderProfileEnum.GS_5_0,
                Header   = header,
                Name     = String.Format("gs_[{0}][{1}]{2}", file, func, header != null ? header.Replace(Environment.NewLine, "_") : "")
            };

            GsObjects[id.Index] = null;

            if (streamOut.HasValue)
            {
                StreamOutputs[id] = streamOut.Value;
            }

            InitGs(id);
            GsIndex.Add(id);

            return(id);
        }
        internal unsafe MyFoliageGeneratingPass()
        {
            var soElements = new StreamOutputElement[2];
            soElements[0].Stream = 0;
            soElements[0].SemanticName = "TEXCOORD";
            soElements[0].SemanticIndex = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot = 0;
            soElements[1].Stream = 0;
            soElements[1].SemanticName = "TEXCOORD";
            soElements[1].SemanticIndex = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            if(m_geometryShader == GeometryShaderId.NULL)
            {
                string stageFile = Path.Combine(MyMaterialShaders.PassesFolder, MyMaterialShaders.FOLIAGE_STREAMING_PASS, "GeometryStage.hlsl");
                m_geometryShader = MyShaders.CreateGs(stageFile, null, new MyShaderStreamOutputInfo { Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream });
            }

            SetImmediate(true);
        }
Exemplo n.º 10
0
        internal static void InitGs(GeometryShaderId id)
        {
            var bytecodeId = GeometryShaders.Data[id.Index].Bytecode;
            Compile(bytecodeId);

            if (GsObjects[id.Index] != null)
            {
                GsObjects[id.Index].Dispose();
                GsObjects[id.Index] = null;
            }

            try
            { 
                if(StreamOutputs.ContainsKey(id))
                {
                    var so = StreamOutputs[id];

                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId), 
                        so.Elements, so.Strides, so.RasterizerStreams, null);
                }
                else
                {
                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId));
                }
            }
            catch (SharpDXException e)
            {
                Compile(bytecodeId, true);

                if (StreamOutputs.ContainsKey(id))
                {
                    var so = StreamOutputs[id];

                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId),
                        so.Elements, so.Strides, so.RasterizerStreams, null);
                }
                else
                {
                    GsObjects[id.Index] = new GeometryShader(MyRender11.Device, GetBytecode(bytecodeId));
                }
            }
        }
Exemplo n.º 11
0
 internal static GeometryShader GetGs(GeometryShaderId id)
 {
     return GsObjects[id.Index];
 }
Exemplo n.º 12
0
        internal static GeometryShaderId CreateGs(string file, string func, string header = "", MyShaderStreamOutputInfo ? streamOut = null)
        {
            var bytecode = CreateBytecode();

            var id = new GeometryShaderId { Index = GeometryShaders.Allocate() };
            GeometryShaders.Data[id.Index] = new MyShaderInfo
            {
                Bytecode = bytecode
            };
            MyArrayHelpers.Reserve(ref GsObjects, id.Index + 1);

            // compile at once

            Shaders[bytecode] = new MyShaderCompilationInfo
            {
                File = MyStringId.GetOrCompute(file),
                Function = MyStringId.GetOrCompute(func),
                Profile = MyShaderProfileEnum.GS_5_0,
                Header = header,
                Name = String.Format("gs_[{0}][{1}]{2}", file, func, header != null ? header.Replace(Environment.NewLine, "_") : "")
            };

            GsObjects[id.Index] = null;

            if(streamOut.HasValue)
            {
                StreamOutputs[id] = streamOut.Value;
            }

            InitGs(id);
            GsIndex.Add(id);

            return id;
        }
Exemplo n.º 13
0
 internal static GeometryShader GetGs(GeometryShaderId id)
 {
     return(GsObjects[id.Index]);
 }
Exemplo n.º 14
0
 internal static void Init()
 {
     m_VS = MyShaders.CreateVs("foliage2.hlsl", "vs");
     m_GS = MyShaders.CreateGs("foliage2.hlsl", "gs");
     m_PS = MyShaders.CreatePs("foliage2.hlsl", "ps");
     m_inputLayout = MyShaders.CreateIL(m_VS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.CUSTOM_UNORM4_0));
 }
Exemplo n.º 15
0
        internal static unsafe void Init()
        {
            var soElements = new StreamOutputElement[2];
            soElements[0].Stream = 0;
            soElements[0].SemanticName = "TEXCOORD";
            soElements[0].SemanticIndex = 0;
            soElements[0].ComponentCount = 3;
            soElements[0].OutputSlot = 0;
            soElements[1].Stream = 0;
            soElements[1].SemanticName = "TEXCOORD";
            soElements[1].SemanticIndex = 1;
            soElements[1].ComponentCount = 1;
            soElements[1].OutputSlot = 0;

            var soStrides = new int[] { sizeof(Vector3) + sizeof(uint) };

            m_gs = MyShaders.CreateGs("passes/foliage_streaming/geometry_stage.hlsl", "gs", "", new MyShaderStreamOutputInfo { Elements = soElements, Strides = soStrides, RasterizerStreams = GeometryShader.StreamOutputNoRasterizedStream });

            m_instance.SetImmediate(true);
        }
Exemplo n.º 16
0
        internal static GeometryShaderId CreateGs(string file, ShaderMacro[] macros = null, MyShaderStreamOutputInfo? streamOut = null)
        {
            var bytecode = CreateBytecode();

            var id = new GeometryShaderId { Index = GeometryShaders.Allocate() };
            GeometryShaders.Data[id.Index] = new MyShaderInfo
            {
                Bytecode = bytecode
            };
            MyArrayHelpers.Reserve(ref GsObjects, id.Index + 1);

            // compile at once

            Shaders[bytecode] = new MyShaderCompilationInfo
            {
                File = X.TEXT_(file),
                Profile = MyShadersDefines.Profiles.gs_5_0,
                Macros = macros
            };

            GsObjects[id.Index] = null;

            if (streamOut.HasValue)
            {
                StreamOutputs[id] = streamOut.Value;
            }

            InitGs(id, file);
            GsIndex.Add(id);
            GsObjects[id.Index].DebugName = file;

            return id;
        }