Пример #1
0
        internal static ComputeShaderId CreateCs(string file, ShaderMacro[] macros = null)
        {
            var bytecode = CreateBytecode();

            var id = new ComputeShaderId {
                Index = ComputeShaders.Allocate()
            };

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

            // compile at once

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

            CsObjects[id.Index] = null;

            InitCs(id, file);
            CsIndex.Add(id);

            return(id);
        }
Пример #2
0
        private void InitShaders()
        {
            if (m_markVS == VertexShaderId.NULL)
            {
                m_markVS = MyShaders.CreateVs("shape.hlsl");
            }

            if (m_markPS == PixelShaderId.NULL)
            {
                m_markPS = MyShaders.CreatePs("shape.hlsl");
            }

            if (m_inputLayout == InputLayoutId.NULL)
            {
                m_inputLayout = MyShaders.CreateIL(m_markVS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));
            }

            if (m_combinePS == PixelShaderId.NULL)
            {
                m_combinePS = MyShaders.CreatePs("CombineShadows.hlsl");
            }

            m_gatherCS_LD = MyShaders.CreateCs("shadows.hlsl");
            m_gatherCS_MD = MyShaders.CreateCs("shadows.hlsl", new [] { new ShaderMacro("ENABLE_PCF", null) });
            m_gatherCS_HD = MyShaders.CreateCs("shadows.hlsl", new[] { new ShaderMacro("ENABLE_PCF", null), new ShaderMacro("ENABLE_DISTORTION", null) });
        }
        internal static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("histogram.hlsl", "build_histogram", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_drawHistogram = MyShaders.CreatePs("data_visualization.hlsl", "display_histogram");

            m_histogram = MyRwTextures.CreateUav1D(512, SharpDX.DXGI.Format.R32_UInt, "histogram");
        }
Пример #4
0
        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_screenVertexShader      = MyShaders.CreateVs("Debug/DebugBaseColor.hlsl");
            m_baseColorShader         = MyShaders.CreatePs("Debug/DebugBaseColor.hlsl");
            m_albedoShader            = MyShaders.CreatePs("Debug/DebugAlbedo.hlsl");
            m_normalShader            = MyShaders.CreatePs("Debug/DebugNormal.hlsl");
            m_normalViewShader        = MyShaders.CreatePs("Debug/DebugNormalView.hlsl");
            m_glossinessShader        = MyShaders.CreatePs("Debug/DebugGlossiness.hlsl");
            m_metalnessShader         = MyShaders.CreatePs("Debug/DebugMetalness.hlsl");
            m_aoShader                = MyShaders.CreatePs("Debug/DebugAmbientOcclusion.hlsl");
            m_emissiveShader          = MyShaders.CreatePs("Debug/DebugEmissive.hlsl");
            m_ambientDiffuseShader    = MyShaders.CreatePs("Debug/DebugAmbientDiffuse.hlsl");
            m_ambientSpecularShader   = MyShaders.CreatePs("Debug/DebugAmbientSpecular.hlsl");
            m_edgeDebugShader         = MyShaders.CreatePs("Debug/DebugEdge.hlsl");
            m_shadowsDebugShader      = MyShaders.CreatePs("Debug/DebugCascadesShadow.hlsl");
            m_NDotLShader             = MyShaders.CreatePs("Debug/DebugNDotL.hlsl");
            m_LODShader               = MyShaders.CreatePs("Debug/DebugLOD.hlsl");
            m_depthShader             = MyShaders.CreatePs("Debug/DebugDepth.hlsl");
            m_depthReprojectionShader = MyShaders.CreateCs("Debug/DebugDepthReprojection.hlsl");
            m_stencilShader           = MyShaders.CreatePs("Debug/DebugStencil.hlsl");
            m_rtShader                = MyShaders.CreatePs("Debug/DebugRt.hlsl");

            m_blitTextureShader      = MyShaders.CreatePs("Debug/DebugBlitTexture.hlsl");
            m_blitTexture3DShader    = MyShaders.CreatePs("Debug/DebugBlitTexture3D.hlsl");
            m_blitTextureArrayShader = MyShaders.CreatePs("Debug/DebugBlitTextureArray.hlsl");
            m_inputLayout            = MyShaders.CreateIL(m_screenVertexShader.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION2, MyVertexInputComponentType.TEXCOORD0));

            m_quadBuffer = MyManagers.Buffers.CreateVertexBuffer(
                "MyDebugRenderer quad", 6, MyVertexFormatPosition2Texcoord.STRIDE,
                usage: ResourceUsage.Dynamic);
        }
Пример #5
0
        internal static void Init()
        {
            MyGPUEmitters.Init();

            m_resetSystem = true;

            m_csInitDeadList   = MyShaders.CreateCs("Transparent/GPUParticles/InitDeadList.hlsl", null);
            m_csResetParticles = MyShaders.CreateCs("Transparent/GPUParticles/Reset.hlsl", null);
            m_csEmit           = MyShaders.CreateCs("Transparent/GPUParticles/Emit.hlsl", null);
            m_csEmitSkipFix    = MyShaders.CreateCs("Transparent/GPUParticles/EmitSkipFix.hlsl", null);
            m_csSimulate       = MyShaders.CreateCs("Transparent/GPUParticles/Simulation.hlsl", null);

            var macrosRender    = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null) };
            var macrosRenderOIT = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) };

            m_vs    = MyShaders.CreateVs("Transparent/GPUParticles/Render.hlsl", macrosRender);
            m_ps    = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", macrosRender);
            m_psOIT = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", macrosRenderOIT);

            var macroDebug = new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null) };

            m_psDebugUniformAccum    = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", MyShaders.ConcatenateMacros(macrosRender, macroDebug));
            m_psDebugUniformAccumOIT = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", MyShaders.ConcatenateMacros(macrosRenderOIT, macroDebug));

            InitDevice();
        }
Пример #6
0
        public static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("Debug/Histogram.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
            m_drawHistogram  = MyShaders.CreatePs("Debug/DataVisualizationHistogram.hlsl");

            m_psDisplayHdrIntensity = MyShaders.CreatePs("Debug/DisplayHdrIntensity.hlsl");
        }
        internal static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("histogram.hlsl", "build_histogram", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_drawHistogram  = MyShaders.CreatePs("data_visualization.hlsl", "display_histogram");

            m_histogram = MyRwTextures.CreateUav1D(512, SharpDX.DXGI.Format.R32_UInt, "histogram");
        }
Пример #8
0
 internal static void Init()
 {
     m_ps        = MyShaders.CreatePs("ForwardPostprocess.hlsl", "apply_skybox");
     m_mipmap    = MyShaders.CreateCs("EnvPrefiltering.hlsl", "buildMipmap");
     m_prefilter = MyShaders.CreateCs("EnvPrefiltering.hlsl", "prefilter");
     m_blend     = MyShaders.CreateCs("EnvPrefiltering.hlsl", "blend");
 }
Пример #9
0
        internal static ComputeShaderId CreateCs(string file, string func, string header = "")
        {
            var bytecode = CreateBytecode();

            var id = new ComputeShaderId {
                Index = ComputeShaders.Allocate()
            };

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

            // compile at once

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

            CsObjects[id.Index] = null;

            InitCs(id);
            CsIndex.Add(id);

            return(id);
        }
Пример #10
0
        public static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("Debug/Histogram.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
            m_drawHistogram = MyShaders.CreatePs("Debug/DataVisualizationHistogram.hlsl");

            m_psDisplayHdrIntensity = MyShaders.CreatePs("Debug/DisplayHdrIntensity.hlsl");
        }
Пример #11
0
 internal static void Init()
 {
     m_ps = MyShaders.CreatePs("ForwardPostprocess.hlsl", "apply_skybox");
     m_mipmap = MyShaders.CreateCs("EnvPrefiltering.hlsl", "buildMipmap");
     m_prefilter = MyShaders.CreateCs("EnvPrefiltering.hlsl", "prefilter");
     m_blend = MyShaders.CreateCs("EnvPrefiltering.hlsl", "blend");
 }
Пример #12
0
        //internal static void RecreateShadersForSettings()
        //{
        //    m_bloomShader = MyShaderFactory.CreateCS("tonemapping.hlsl", "bloom_initial", MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine(), "NUMTHREADS 8"));
        //}

        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_bloomShader = MyShaders.CreateCs("tonemapping.hlsl", "bloom_initial", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_downscaleShader = MyShaders.CreateCs("tonemapping.hlsl", "downscale", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_blurH = MyShaders.CreateCs("tonemapping.hlsl", "blur_h", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_blurV = MyShaders.CreateCs("tonemapping.hlsl", "blur_v", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
        }
Пример #13
0
        //internal static void RecreateShadersForSettings()
        //{
        //    m_bloomShader = MyShaderFactory.CreateCS("tonemapping.hlsl", "bloom_initial", MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine(), "NUMTHREADS 8"));
        //}

        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_bloomShader     = MyShaders.CreateCs("tonemapping.hlsl", "bloom_initial", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_downscaleShader = MyShaders.CreateCs("tonemapping.hlsl", "downscale", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_blurH           = MyShaders.CreateCs("tonemapping.hlsl", "blur_h", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
            m_blurV           = MyShaders.CreateCs("tonemapping.hlsl", "blur_v", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
        }
Пример #14
0
 internal static void Init()
 {
     m_ps = MyShaders.CreatePs("EnvProbe/ForwardPostprocess.hlsl");
     m_atmosphere = MyShaders.CreatePs("EnvProbe/AtmospherePostprocess.hlsl");
     m_mipmap = MyShaders.CreateCs("EnvProbe/EnvPrefilteringMipmap.hlsl");
     m_prefilter = MyShaders.CreateCs("EnvProbe/EnvPrefiltering.hlsl");
     m_blend = MyShaders.CreateCs("EnvProbe/EnvPrefilteringBlend.hlsl");
 }
Пример #15
0
 internal static void Init()
 {
     m_ps         = MyShaders.CreatePs("ForwardPostprocess.hlsl");
     m_atmosphere = MyShaders.CreatePs("AtmospherePostprocess.hlsl");
     m_mipmap     = MyShaders.CreateCs("EnvPrefiltering_mipmap.hlsl");
     m_prefilter  = MyShaders.CreateCs("EnvPrefiltering.hlsl");
     m_blend      = MyShaders.CreateCs("EnvPrefiltering_blend.hlsl");
 }
Пример #16
0
        internal static void Init()
        {
            m_buildHistogram  = MyShaders.CreateCs("histogram.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
            m_drawHistogram   = MyShaders.CreatePs("data_visualization_histogram.hlsl");
            m_drawTonemapping = MyShaders.CreatePs("data_visualization_tonemapping.hlsl");

            m_histogram = MyRwTextures.CreateUav1D(513, SharpDX.DXGI.Format.R32_UInt, "histogram");
        }
        internal static void Init()
        {
            var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };

            m_initialShader = MyShaders.CreateCs("luminance_reduction_init.hlsl", threadMacro);
            m_sumShader     = MyShaders.CreateCs("luminance_reduction.hlsl", threadMacro);
            m_finalShader   = MyShaders.CreateCs("luminance_reduction.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8), new ShaderMacro("_FINAL", null) });
        }
        internal static void Init()
        {
            m_buildHistogram = MyShaders.CreateCs("histogram.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
            m_drawHistogram = MyShaders.CreatePs("data_visualization_histogram.hlsl");
            m_drawTonemapping = MyShaders.CreatePs("data_visualization_tonemapping.hlsl");

            m_histogram = MyRwTextures.CreateUav1D(513, SharpDX.DXGI.Format.R32_UInt, "histogram");
        }
Пример #19
0
 internal static void Init()
 {
     var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };
     //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
     m_bloomShader = MyShaders.CreateCs("bloom_init.hlsl",threadMacro);
     m_downscaleShader = MyShaders.CreateCs("bloom_downscale.hlsl", threadMacro);
     m_blurH = MyShaders.CreateCs("bloom_blur_h.hlsl", threadMacro);
     m_blurV = MyShaders.CreateCs("bloom_blur_v.hlsl", threadMacro);
 }
        internal static void Init()
        {
            var threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS) };
            m_initialShader = MyShaders.CreateCs("luminance_reduction_init.hlsl", threadMacros);
            m_sumShader = MyShaders.CreateCs("luminance_reduction.hlsl", threadMacros);

            threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS), new ShaderMacro("_FINAL", null) };
            m_finalShader = MyShaders.CreateCs("luminance_reduction.hlsl", threadMacros);
        }
Пример #21
0
        internal static void Init()
        {
            var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };

            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_bloomShader     = MyShaders.CreateCs("bloom_init.hlsl", threadMacro);
            m_downscaleShader = MyShaders.CreateCs("bloom_downscale.hlsl", threadMacro);
            m_blurH           = MyShaders.CreateCs("bloom_blur_h.hlsl", threadMacro);
            m_blurV           = MyShaders.CreateCs("bloom_blur_v.hlsl", threadMacro);
        }
Пример #22
0
        internal static unsafe void Init()
        {
            m_ps = MyShaders.CreatePs("EnvProbe/ForwardPostprocess.hlsl");
            //m_atmosphere = MyShaders.CreatePs("EnvProbe/AtmospherePostprocess.hlsl");
            m_mipmap    = MyShaders.CreateCs("EnvProbe/EnvPrefilteringMipmap.hlsl");
            m_prefilter = MyShaders.CreateCs("EnvProbe/EnvPrefiltering.hlsl");
            m_blend     = MyShaders.CreateCs("EnvProbe/EnvPrefilteringBlend.hlsl");

            TransformConstants = MyManagers.Buffers.CreateConstantBuffer("TransformConstants", sizeof(Matrix) * 2 + sizeof(Vector4), usage: ResourceUsage.Dynamic);
        }
Пример #23
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;

        internal static void Init()
        {
            m_ps          = MyShaders.CreatePs("atmosphere.hlsl");
            m_psPerSample = MyShaders.CreatePs("atmosphere.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_precomputeDensity = MyShaders.CreateCs("AtmospherePrecompute.hlsl");

            m_proxyVs = MyShaders.CreateVs("atmosphere.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));
        }
Пример #24
0
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("Transparent/Clouds/Clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("Transparent/Clouds/Clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                    new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                    new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                    new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                    new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("Transparent/Clouds/Clouds.hlsl", new[] { new ShaderMacro("NUMTHREADS", m_numFogThreads) });
        }
Пример #25
0
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("Transparent/Clouds/Clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("Transparent/Clouds/Clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                                               new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                                               new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("Transparent/Clouds/Clouds.hlsl", new[] { new ShaderMacro("NUMTHREADS", m_numFogThreads) });
        }
Пример #26
0
        internal static void Init()
        {
            var threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS) };
            m_initialShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Init.hlsl", threadMacros);
            m_sumShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros);

            threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS), new ShaderMacro("_FINAL", null) };
            m_finalShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros);

            m_skipShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Skip.hlsl");

            m_prevLum = MyManagers.RwTextures.CreateUav("MyLuminanceAverage.PrevLum", 1, 1, Format.R32G32_Float);
        }
Пример #27
0
        internal static void Init()
        {
            var threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS) };

            m_initialShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Init.hlsl", threadMacros);
            m_sumShader     = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros);

            threadMacros  = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS), new ShaderMacro("_FINAL", null) };
            m_finalShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Sum.hlsl", threadMacros);

            m_skipShader = MyShaders.CreateCs("Postprocess/LuminanceReduction/Skip.hlsl");

            m_prevLum = MyManagers.RwTextures.CreateUav("MyLuminanceAverage.PrevLum", 1, 1, Format.R32G32_Float);
        }
Пример #28
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;
        

        internal static void Init()
        {
            m_ps = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereInscatter");
            m_psT = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereTransmittance");
            m_psPerSample = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereInscatter", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));
            m_psTPerSample = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereTransmittance", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            m_precomputeDensity = MyShaders.CreateCs("AtmospherePrecompute.hlsl", "precomputeDensity");
            m_precomputeInscatter1 = MyShaders.CreateCs("AtmospherePrecompute.hlsl", "precomputeInscatter1");

            m_proxyVs = MyShaders.CreateVs("atmosphere.hlsl", "proxyVs");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            //Precompute();
        }
Пример #29
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;


        internal static void Init()
        {
            m_ps           = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereInscatter");
            m_psT          = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereTransmittance");
            m_psPerSample  = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereInscatter", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));
            m_psTPerSample = MyShaders.CreatePs("atmosphere.hlsl", "psAtmosphereTransmittance", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            m_precomputeDensity    = MyShaders.CreateCs("AtmospherePrecompute.hlsl", "precomputeDensity");
            m_precomputeInscatter1 = MyShaders.CreateCs("AtmospherePrecompute.hlsl", "precomputeInscatter1");

            m_proxyVs = MyShaders.CreateVs("atmosphere.hlsl", "proxyVs");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            //Precompute();
        }
Пример #30
0
        internal static void OnDeviceEnd()
        {
            DoneDevice();

            m_ps    = PixelShaderId.NULL;
            m_psOIT = PixelShaderId.NULL;
            m_vs    = VertexShaderId.NULL;

            m_csSimulate = ComputeShaderId.NULL;

            m_csResetParticles = ComputeShaderId.NULL;
            m_csInitDeadList   = ComputeShaderId.NULL;
            m_csEmit           = ComputeShaderId.NULL;

            m_resetSystem = true;
        }
Пример #31
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;

        internal static unsafe void Init()
        {
            m_ps          = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereGBuffer.hlsl");
            m_psPerSample = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereGBuffer.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_psEnv          = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereEnv.hlsl");
            m_psEnvPerSample = MyShaders.CreatePs("Transparent/Atmosphere/AtmosphereEnv.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_precomputeDensity = MyShaders.CreateCs("Transparent/Atmosphere/AtmospherePrecompute.hlsl");

            m_proxyVs = MyShaders.CreateVs("Transparent/Atmosphere/AtmosphereVS.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            m_cb = MyManagers.Buffers.CreateConstantBuffer("CommonObjectCB" + sizeof(AtmosphereConstants), sizeof(AtmosphereConstants),
                                                           usage: SharpDX.Direct3D11.ResourceUsage.Dynamic);
        }
        private void InitShaders()
        {
            if (m_markVS == VertexShaderId.NULL)
                m_markVS = MyShaders.CreateVs("ShadowsOld/Shape.hlsl");

            if (m_markPS == PixelShaderId.NULL)
                m_markPS = MyShaders.CreatePs("ShadowsOld/Shape.hlsl");

            if (m_inputLayout == InputLayoutId.NULL)
                m_inputLayout = MyShaders.CreateIL(m_markVS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));

            if (m_combinePS == PixelShaderId.NULL)
                m_combinePS = MyShaders.CreatePs("ShadowsOld/CombineShadows.hlsl");

            m_gatherCS_LD = MyShaders.CreateCs("ShadowsOld/Shadows.hlsl");
            m_gatherCS_MD = MyShaders.CreateCs("ShadowsOld/Shadows.hlsl", new[] { new ShaderMacro("ENABLE_PCF", null) });
            m_gatherCS_HD = MyShaders.CreateCs("ShadowsOld/Shadows.hlsl", new[] { new ShaderMacro("ENABLE_PCF", null), new ShaderMacro("ENABLE_DISTORTION", null) });
        }
Пример #33
0
 internal static void Init()
 {
     var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };
     //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
     m_bloomShader = MyShaders.CreateCs("Postprocess/Bloom/Init.hlsl",threadMacro);
     m_downscale2Shader = MyShaders.CreateCs("Postprocess/Bloom/Downscale2.hlsl", threadMacro);
     m_downscale4Shader = MyShaders.CreateCs("Postprocess/Bloom/Downscale4.hlsl", threadMacro);
     m_blurH = new ComputeShaderId[MAX_GAUSSIAN_SAMPLES];
     m_blurV = new ComputeShaderId[MAX_GAUSSIAN_SAMPLES];
     for (int i = 0; i < MAX_GAUSSIAN_SAMPLES; i ++)
     {
         var macros = new[] {new ShaderMacro("HORIZONTAL", null), new ShaderMacro("NUMTHREADS", 8), 
             new ShaderMacro("NUM_GAUSSIAN_SAMPLES", ((i % 2) > 0)? (i + 1) : i)};
         m_blurH[i] = MyShaders.CreateCs("Postprocess/Bloom/Blur.hlsl", macros);
         macros = new[] {new ShaderMacro("NUMTHREADS", 8), 
             new ShaderMacro("NUM_GAUSSIAN_SAMPLES", ((i % 2) > 0)? (i + 1) : i)};
         m_blurV[i] = MyShaders.CreateCs("Postprocess/Bloom/Blur.hlsl", macros);
     }
 }
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

            DirectionalEnvironmentLight_Pixel  = MyShaders.CreatePs("Lighting/LightDir.hlsl");
            DirectionalEnvironmentLight_Sample = MyShaders.CreatePs("Lighting/LightDir.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            PointlightsTiled_Pixel  = MyShaders.CreatePs("Lighting/LightPoint.hlsl");
            PointlightsTiled_Sample = MyShaders.CreatePs("Lighting/LightPoint.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_preparePointLights = MyShaders.CreateCs("Lighting/PrepareLights.hlsl", new[] { new ShaderMacro("NUMTHREADS", TILE_SIZE) });

            SpotlightProxyVs   = MyShaders.CreateVs("Lighting/LightSpot.hlsl");
            SpotlightPs_Pixel  = MyShaders.CreatePs("Lighting/LightSpot.hlsl");
            SpotlightPs_Sample = MyShaders.CreatePs("Lighting/LightSpot.hlsl", MyRender11.ShaderSampleFrequencyDefine());
            SpotlightProxyIL   = MyShaders.CreateIL(SpotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            m_pointlightCullHwBuffer = MyHwBuffers.CreateStructuredBuffer(MyRender11Constants.MAX_POINT_LIGHTS, sizeof(MyPointlightConstants), true, null, "MyLightRendering");
        }
Пример #35
0
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

			DirectionalEnvironmentLight_Pixel = MyShaders.CreatePs("Lighting/LightDir.hlsl");
            DirectionalEnvironmentLight_Sample = MyShaders.CreatePs("Lighting/LightDir.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            PointlightsTiled_Pixel = MyShaders.CreatePs("Lighting/LightPoint.hlsl");
            PointlightsTiled_Sample = MyShaders.CreatePs("Lighting/LightPoint.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_preparePointLights = MyShaders.CreateCs("Lighting/PrepareLights.hlsl", new[] { new ShaderMacro("NUMTHREADS", TILE_SIZE) });

            SpotlightProxyVs = MyShaders.CreateVs("Lighting/LightSpot.hlsl");
            SpotlightPs_Pixel = MyShaders.CreatePs("Lighting/LightSpot.hlsl");
            SpotlightPs_Sample = MyShaders.CreatePs("Lighting/LightSpot.hlsl", MyRender11.ShaderSampleFrequencyDefine());
            SpotlightProxyIL = MyShaders.CreateIL(SpotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            m_pointlightCullHwBuffer = MyHwBuffers.CreateStructuredBuffer(MyRender11Constants.MAX_POINT_LIGHTS, sizeof(MyPointlightConstants), true, null, "MyLightRendering");
        }
Пример #36
0
        internal static void Init()
        {
            var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };

            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_bloomShader      = MyShaders.CreateCs("Postprocess/Bloom/Init.hlsl", threadMacro);
            m_downscale2Shader = MyShaders.CreateCs("Postprocess/Bloom/Downscale2.hlsl", threadMacro);
            m_downscale4Shader = MyShaders.CreateCs("Postprocess/Bloom/Downscale4.hlsl", threadMacro);
            m_blurH            = new ComputeShaderId[MAX_GAUSSIAN_SAMPLES];
            m_blurV            = new ComputeShaderId[MAX_GAUSSIAN_SAMPLES];
            for (int i = 0; i < MAX_GAUSSIAN_SAMPLES; i++)
            {
                var macros = new[] { new ShaderMacro("HORIZONTAL", null), new ShaderMacro("NUMTHREADS", 8),
                                     new ShaderMacro("NUM_GAUSSIAN_SAMPLES", ((i % 2) > 0)? (i + 1) : i) };
                m_blurH[i] = MyShaders.CreateCs("Postprocess/Bloom/Blur.hlsl", macros);
                macros     = new[] { new ShaderMacro("NUMTHREADS", 8),
                                     new ShaderMacro("NUM_GAUSSIAN_SAMPLES", ((i % 2) > 0)? (i + 1) : i) };
                m_blurV[i] = MyShaders.CreateCs("Postprocess/Bloom/Blur.hlsl", macros);
            }
        }
Пример #37
0
        internal static void Init()
        {
            MyGPUEmitters.Init();

            m_resetSystem = true;

            m_csInitDeadList   = MyShaders.CreateCs("Particles/InitDeadList.hlsl", null);
            m_csResetParticles = MyShaders.CreateCs("Particles/Reset.hlsl", null);
            m_csEmit           = MyShaders.CreateCs("Particles/Emit.hlsl", null);
            m_csSimulate       = MyShaders.CreateCs("Particles/Simulation.hlsl", null);

            var macrosRender    = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null) };
            var macrosRenderOIT = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) };

            m_vs    = MyShaders.CreateVs("Particles/Render.hlsl", macrosRender);
            m_ps    = MyShaders.CreatePs("Particles/Render.hlsl", macrosRender);
            m_psOIT = MyShaders.CreatePs("Particles/Render.hlsl", macrosRenderOIT);

            InitDevice();
        }
Пример #38
0
        internal static void InitCs(ComputeShaderId id)
        {
            var bytecodeId = ComputeShaders.Data[id.Index].Bytecode;

            Compile(bytecodeId);

            if (CsObjects[id.Index] != null)
            {
                CsObjects[id.Index].Dispose();
                CsObjects[id.Index] = null;
            }
            try
            {
                CsObjects[id.Index] = new ComputeShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
            catch (SharpDXException e)
            {
                Compile(bytecodeId, true);
                CsObjects[id.Index] = new ComputeShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
        }
Пример #39
0
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                    new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                    new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                    new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                    new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("clouds.hlsl", new [] {new ShaderMacro("NUMTHREADS", m_numFogThreads)});

            SamplerStateDescription description = new SamplerStateDescription
            {
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Wrap,
                AddressW = TextureAddressMode.Wrap,
                Filter = Filter.MinMagMipLinear,
                MaximumLod = System.Single.MaxValue
            };
            m_textureSampler = MyPipelineStates.CreateSamplerState(description);
        }
Пример #40
0
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                                               new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                                               new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("clouds.hlsl", new [] { new ShaderMacro("NUMTHREADS", m_numFogThreads) });

            SamplerStateDescription description = new SamplerStateDescription
            {
                AddressU   = TextureAddressMode.Wrap,
                AddressV   = TextureAddressMode.Wrap,
                AddressW   = TextureAddressMode.Wrap,
                Filter     = Filter.MinMagMipLinear,
                MaximumLod = System.Single.MaxValue
            };

            m_textureSampler = MyPipelineStates.CreateSamplerState(description);
        }
Пример #41
0
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

            DirectionalEnvironmentLight_Pixel  = MyShaders.CreatePs("light.hlsl", "directional_environment");
            DirectionalEnvironmentLight_Sample = MyShaders.CreatePs("light.hlsl", "directional_environment", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            PointlightsTiled_Pixel  = MyShaders.CreatePs("light.hlsl", "pointlights_tiled");
            PointlightsTiled_Sample = MyShaders.CreatePs("light.hlsl", "pointlights_tiled", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            m_preparePointLights = MyShaders.CreateCs("prepare_lights.hlsl", "prepare_lights", MyShaderHelpers.FormatMacros("NUMTHREADS " + TILE_SIZE));

            SpotlightProxyVs = MyShaders.CreateVs("light.hlsl", "spotlightVs");
            SpotlightPs      = MyShaders.CreatePs("light.hlsl", "spotlightFromProxy");
            SpotlightProxyIL = MyShaders.CreateIL(SpotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            var stride = sizeof(MyPointlightConstants);

            m_pointlightCullHwBuffer = MyHwBuffers.CreateStructuredBuffer(MyRender11Constants.MAX_POINT_LIGHTS, stride, true);
            m_pointlightsConstants   = MyHwBuffers.CreateConstantsBuffer(sizeof(MyPointlightInfo) * MyRender11Constants.MAX_POINT_LIGHTS);
            m_spotlightsConstants    = MyHwBuffers.CreateConstantsBuffer(sizeof(MySpotlightConstants) * MyRender11Constants.MAX_SPOTLIGHTS);
            m_sunlightConstants      = MyHwBuffers.CreateConstantsBuffer(sizeof(MySunlightConstantsLayout));
        }
Пример #42
0
        internal static void OnDeviceEnd()
        {
            DoneDevice();

            m_ps = PixelShaderId.NULL;
            m_psOIT = PixelShaderId.NULL;
            m_vs = VertexShaderId.NULL;

            m_csSimulate = ComputeShaderId.NULL;

            m_csResetParticles = ComputeShaderId.NULL;
            m_csInitDeadList = ComputeShaderId.NULL;
            m_csEmit = ComputeShaderId.NULL;
            m_csEmitSkipFix = ComputeShaderId.NULL;

            m_resetSystem = true;
        }
Пример #43
0
        internal static void Init()
        {
            MyGPUEmitters.Init();

            m_resetSystem = true;

            m_csInitDeadList = MyShaders.CreateCs("Transparent/GPUParticles/InitDeadList.hlsl", null);
            m_csResetParticles = MyShaders.CreateCs("Transparent/GPUParticles/Reset.hlsl", null);
            m_csEmit = MyShaders.CreateCs("Transparent/GPUParticles/Emit.hlsl", null);
            m_csEmitSkipFix = MyShaders.CreateCs("Transparent/GPUParticles/EmitSkipFix.hlsl", null);
            m_csSimulate = MyShaders.CreateCs("Transparent/GPUParticles/Simulation.hlsl", null);

            var macrosRender = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null) };
            var macrosRenderOIT = new[] { new ShaderMacro("STREAKS", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) };
            m_vs = MyShaders.CreateVs("Transparent/GPUParticles/Render.hlsl", macrosRender);
            m_ps = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", macrosRender);
            m_psOIT = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", macrosRenderOIT);

            var macroDebug = new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null) };
            m_psDebugUniformAccum = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", MyShaders.ConcatenateMacros(macrosRender, macroDebug));
            m_psDebugUniformAccumOIT = MyShaders.CreatePs("Transparent/GPUParticles/Render.hlsl", MyShaders.ConcatenateMacros(macrosRenderOIT, macroDebug));

            InitDevice();
        }
Пример #44
0
 internal static new void Init()
 {
     m_gather = MyShaders.CreateCs("shadows.hlsl", "write_shadow", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads) + MyRender11.ShaderCascadesNumberHeader());
     m_blur_h = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, MyRender11.ShaderCascadesNumberDefine()));
     m_blur_v = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, "VERTICAL", MyRender11.ShaderCascadesNumberDefine()));
 }
Пример #45
0
 internal static void Init()
 {
     m_cs = MyShaders.CreateCs("tonemapping.hlsl", "tonemapping", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_csSkip = MyShaders.CreateCs("tonemapping.hlsl", "tonemapping", MyShaderHelpers.FormatMacros("NUMTHREADS 8", "DISABLE_TONEMAPPING"));
 }
Пример #46
0
        // inscatter texture
        // transmittance texture
        //static RwTexId m_transmittanceLut;
        //static RwTexId m_inscatterLutR;
        //static RwTexId m_inscatterLutM;

        internal static void Init()
        {
            m_ps = MyShaders.CreatePs("Transparent/Atmosphere/Atmosphere.hlsl");
            m_psPerSample = MyShaders.CreatePs("Transparent/Atmosphere/Atmosphere.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_precomputeDensity = MyShaders.CreateCs("Transparent/Atmosphere/AtmospherePrecompute.hlsl");

            m_proxyVs = MyShaders.CreateVs("Transparent/Atmosphere/Atmosphere.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));
        }
Пример #47
0
 internal static ComputeShader GetCs(ComputeShaderId id)
 {
     return CsObjects[id.Index];
 }
Пример #48
0
        internal static ComputeShaderId CreateCs(string file, ShaderMacro[] macros = null)
        {
            var bytecode = CreateBytecode();

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

            // compile at once

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

            CsObjects[id.Index] = null;

            InitCs(id, file);
            CsIndex.Add(id);

            return id;
        }
        private void InitShaders()
        {
            if (m_markVS == VertexShaderId.NULL)
                m_markVS = MyShaders.CreateVs("shape.hlsl");

            if (m_markPS == PixelShaderId.NULL)
                m_markPS = MyShaders.CreatePs("shape.hlsl");

            if (m_inputLayout == InputLayoutId.NULL)
                m_inputLayout = MyShaders.CreateIL(m_markVS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));

            if (m_combinePS == PixelShaderId.NULL)
                m_combinePS = MyShaders.CreatePs("CombineShadows.hlsl");

            m_threadGroupCountX = 32;
            m_threadGroupCountY = 32;
            Vector2I pixelCount = MyRender11.ViewportResolution;
            Vector2I threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);

            int tryIndex = 0;
            while(threadsPerThreadGroup.X*threadsPerThreadGroup.Y > 1024)   // Make sure we do are not over the limit of threads per thread group
            {
                if (tryIndex++ % 2 == 0)
                    ++m_threadGroupCountX;
                else
                    ++m_threadGroupCountY;

                threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);
            }

            int pixelsCoveredX = threadsPerThreadGroup.X * m_pixelsPerThreadX * m_threadGroupCountX;
            if (pixelsCoveredX < pixelCount.X)
                ++m_threadGroupCountX;
            int pixelsCoveredY = threadsPerThreadGroup.Y * m_pixelsPerThreadY * m_threadGroupCountY;
            if (pixelsCoveredY < pixelCount.Y)
                ++m_threadGroupCountY;

            m_gatherCS = MyShaders.CreateCs("shadows.hlsl", new [] {
                new ShaderMacro("NUMTHREADS_X", threadsPerThreadGroup.X),
                new ShaderMacro("NUMTHREADS_Y", threadsPerThreadGroup.Y),
                new ShaderMacro("THREAD_GROUPS_X", m_threadGroupCountX),
                new ShaderMacro("THREAD_GROUPS_Y", m_threadGroupCountY),
                new ShaderMacro("PIXELS_PER_THREAD_X", m_pixelsPerThreadX),
                new ShaderMacro("PIXELS_PER_THREAD_Y", m_pixelsPerThreadY)});
        }
Пример #50
0
 internal static void Init()
 {
     m_initialShader = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_init", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_sumShader = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_reduce", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_finalShader = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_reduce", MyShaderHelpers.FormatMacros("NUMTHREADS 8", "_FINAL"));
 }
Пример #51
0
 internal static void Init()
 {
     m_gather = MyShaders.CreateCs("shadows.hlsl", "write_shadow", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads));
     m_blur_h = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads));
     m_blur_v = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, "VERTICAL"));
 }
Пример #52
0
 internal static void Init()
 {
     m_initialShader = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_init", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_sumShader     = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_reduce", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
     m_finalShader   = MyShaders.CreateCs("luminance_reduction.hlsl", "luminance_reduce", MyShaderHelpers.FormatMacros("NUMTHREADS 8", "_FINAL"));
 }
 internal static void Init()
 {
     m_cs = MyShaders.CreateCs("tonemapping.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8) });
     m_csSkip = MyShaders.CreateCs("tonemapping.hlsl", new[] { new ShaderMacro("NUMTHREADS", 8), new ShaderMacro("DISABLE_TONEMAPPING", null) });
 }
Пример #54
0
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

            DirectionalEnvironmentLight_Pixel = MyShaders.CreatePs("light.hlsl", "directional_environment");
            DirectionalEnvironmentLight_Sample = MyShaders.CreatePs("light.hlsl", "directional_environment", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            PointlightsTiled_Pixel = MyShaders.CreatePs("light.hlsl", "pointlights_tiled");
            PointlightsTiled_Sample = MyShaders.CreatePs("light.hlsl", "pointlights_tiled", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));

            m_preparePointLights = MyShaders.CreateCs("prepare_lights.hlsl", "prepare_lights", MyShaderHelpers.FormatMacros("NUMTHREADS " + TILE_SIZE));

            SpotlightProxyVs = MyShaders.CreateVs("light.hlsl", "spotlightVs");
            SpotlightPs_Pixel = MyShaders.CreatePs("light.hlsl", "spotlightFromProxy");
            SpotlightPs_Sample = MyShaders.CreatePs("light.hlsl", "spotlightFromProxy", MyShaderHelpers.FormatMacros(MyRender11.ShaderSampleFrequencyDefine()));
            SpotlightProxyIL = MyShaders.CreateIL(SpotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            var stride = sizeof(MyPointlightConstants);
            m_pointlightCullHwBuffer = MyHwBuffers.CreateStructuredBuffer(MyRender11Constants.MAX_POINT_LIGHTS, stride, true);
            m_pointlightsConstants = MyHwBuffers.CreateConstantsBuffer(sizeof(MyPointlightInfo) * MyRender11Constants.MAX_POINT_LIGHTS);
            m_spotlightsConstants = MyHwBuffers.CreateConstantsBuffer(sizeof(MySpotlightConstants) * MyRender11Constants.MAX_SPOTLIGHTS);
            m_sunlightConstants = MyHwBuffers.CreateConstantsBuffer(sizeof(MySunlightConstantsLayout));
        }
Пример #55
0
 internal static ComputeShader GetCs(ComputeShaderId id)
 {
     return(CsObjects[id.Index]);
 }
Пример #56
0
        private void InitShaders()
        {
            if (m_markVS == VertexShaderId.NULL)
            {
                m_markVS = MyShaders.CreateVs("shape.hlsl");
            }

            if (m_markPS == PixelShaderId.NULL)
            {
                m_markPS = MyShaders.CreatePs("shape.hlsl");
            }

            if (m_inputLayout == InputLayoutId.NULL)
            {
                m_inputLayout = MyShaders.CreateIL(m_markVS.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));
            }

            if (m_combinePS == PixelShaderId.NULL)
            {
                m_combinePS = MyShaders.CreatePs("CombineShadows.hlsl");
            }

            m_threadGroupCountX = 32;
            m_threadGroupCountY = 32;
            Vector2I pixelCount            = MyRender11.ViewportResolution;
            Vector2I threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);

            int tryIndex = 0;

            while (threadsPerThreadGroup.X * threadsPerThreadGroup.Y > 1024)   // Make sure we do are not over the limit of threads per thread group
            {
                if (tryIndex++ % 2 == 0)
                {
                    ++m_threadGroupCountX;
                }
                else
                {
                    ++m_threadGroupCountY;
                }

                threadsPerThreadGroup = GetThreadsPerThreadGroup(pixelCount);
            }

            int pixelsCoveredX = threadsPerThreadGroup.X * m_pixelsPerThreadX * m_threadGroupCountX;

            if (pixelsCoveredX < pixelCount.X)
            {
                ++m_threadGroupCountX;
            }
            int pixelsCoveredY = threadsPerThreadGroup.Y * m_pixelsPerThreadY * m_threadGroupCountY;

            if (pixelsCoveredY < pixelCount.Y)
            {
                ++m_threadGroupCountY;
            }

            m_gatherCS = MyShaders.CreateCs("shadows.hlsl", new [] {
                new ShaderMacro("NUMTHREADS_X", threadsPerThreadGroup.X),
                new ShaderMacro("NUMTHREADS_Y", threadsPerThreadGroup.Y),
                new ShaderMacro("THREAD_GROUPS_X", m_threadGroupCountX),
                new ShaderMacro("THREAD_GROUPS_Y", m_threadGroupCountY),
                new ShaderMacro("PIXELS_PER_THREAD_X", m_pixelsPerThreadX),
                new ShaderMacro("PIXELS_PER_THREAD_Y", m_pixelsPerThreadY)
            });
        }
Пример #57
0
        internal static ComputeShaderId CreateCs(string file, string func, string header = "")
        {
            var bytecode = CreateBytecode();

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

            // compile at once

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

            CsObjects[id.Index] = null;

            InitCs(id);
            CsIndex.Add(id);

            return id;
        }
Пример #58
0
        //internal static void RecreateShadersForSettings()
        //{
        //    m_cs = MyShaderFactory.CreateCS("custom_resolve.hlsl", "resolve_lbuffer", MyShaderHelpers.FormatMacros(MyRender11.ShaderMultisamplingDefine(), "NUMTHREADS 8"));
        //}

        internal static void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
            m_cs = MyShaders.CreateCs("custom_resolve.hlsl", "resolve_lbuffer", MyShaderHelpers.FormatMacros("NUMTHREADS 8"));
        }
Пример #59
0
        internal static void InitCs(ComputeShaderId id)
        {
            var bytecodeId = ComputeShaders.Data[id.Index].Bytecode;
            Compile(bytecodeId);

            if (CsObjects[id.Index] != null)
            {
                CsObjects[id.Index].Dispose();
                CsObjects[id.Index] = null;
            }
            try
            {
                CsObjects[id.Index] = new ComputeShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
            catch (SharpDXException e)
            {
                Compile(bytecodeId, true);
                CsObjects[id.Index] = new ComputeShader(MyRender11.Device, GetBytecode(bytecodeId));
            }
        }
Пример #60
0
        internal static new void Init()
        {
			m_gather = MyShaders.CreateCs("shadows.hlsl", "write_shadow", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads) + MyRender11.ShaderCascadesNumberHeader());
			m_blur_h = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, MyRender11.ShaderCascadesNumberDefine()));
			m_blur_v = MyShaders.CreateCs("shadows.hlsl", "blur", MyShaderHelpers.FormatMacros("NUMTHREADS " + m_numthreads, "VERTICAL", MyRender11.ShaderCascadesNumberDefine()));
        }