Esempio n. 1
0
        public FilterShader(string shaderSource, FilterModel filterModel)
        {
            this.filterModel = filterModel;
            var maxTextureBindings = GL.GetInteger(GetPName.MaxTextureImageUnits);
            // MAX_UNIFORM_LOCATIONS
            var maxUniformLocations = GL.GetInteger((GetPName)(0x826E));

            this.parameterLocationStart = textureLocationStart + filterModel.TextureParameters.Count;

            // test if any binding slots were exceeded
            if (textureBindingStart + filterModel.TextureParameters.Count > maxTextureBindings)
            {
                throw new Exception($"Too many texture bindings. Only {maxTextureBindings} texture bindings are available on this GPU");
            }
            if (parameterLocationStart + filterModel.Parameters.Count > maxUniformLocations)
            {
                throw new Exception($"Too many uniform variables. Only {maxUniformLocations} uniform location bindings are available on this GPU");
            }

            var shader = new glhelper.Shader(ShaderType.ComputeShader,
                                             GetShaderHeader() +
                                             "#line 1\n" +
                                             shaderSource);

            shader.Compile();

            program = new Program(new List <glhelper.Shader> {
                shader
            }, true);
        }
Esempio n. 2
0
        protected void init()
        {
            var shader = new glhelper.Shader(ShaderType.ComputeShader, GetComputeSource()).Compile();

            program = new Program(new List <glhelper.Shader> {
                shader
            }, true);
        }