예제 #1
0
 public GLSLGraphicsPipelineCompilier(
     IGLShaderModuleEntrypoint shaderModule,
     IGLGraphicsPipelineEntrypoint program,
     IGLUniformBlockEntrypoint uniformBlocks,
     IGLErrorHandler errHandler,
     IGLUniformBlockNameParser parser
     )
 {
     mShaderModuleEntrypoint = shaderModule;
     mProgramEntrypoint      = program;
     mErrHandler             = errHandler;
     mUniformBlocks          = uniformBlocks;
     mParser = parser;
 }
예제 #2
0
 public DefaultGLDeviceEntrypoint
 (
     IGLCmdVBOEntrypoint vbo,
     IGLSamplerEntrypoint sampler,
     IGLDeviceImageEntrypoint image,
     IGLDeviceImageViewEntrypoint imageView,
     IGLImageDescriptorEntrypoint imageDescriptor,
     IGLShaderModuleEntrypoint shaderModule,
     IGLDescriptorPoolEntrypoint descriptorPool,
     IGLBufferEntrypoint buffers,
     IGLDeviceMemoryEntrypoint deviceMemory,
     IGLSemaphoreEntrypoint semaphore,
     IGLGraphicsPipelineEntrypoint graphicsPipeline,
     IGLImageFormatEntrypoint imageFormat,
     IGLGraphicsPipelineCompiler graphicsCompiler,
     IGLFenceEntrypoint fence,
     IGLCmdShaderProgramEntrypoint shaderProgram,
     IGLDescriptorSetEntrypoint descriptorSet,
     IGLUniformBlockEntrypoint uniformBlocks
 )
 {
     VBO              = vbo;
     Sampler          = sampler;
     Image            = image;
     ImageView        = imageView;
     ImageDescriptor  = imageDescriptor;
     ShaderModule     = shaderModule;
     DescriptorPool   = descriptorPool;
     Buffers          = buffers;
     DeviceMemory     = deviceMemory;
     Semaphore        = semaphore;
     GraphicsPipeline = graphicsPipeline;
     ImageFormat      = imageFormat;
     GraphicsCompiler = graphicsCompiler;
     Fence            = fence;
     ShaderProgram    = shaderProgram;
     DescriptorSet    = descriptorSet;
     UniformBlocks    = uniformBlocks;
 }
예제 #3
0
        internal static int CompileShader(IGLShaderModuleEntrypoint entrypoint, MgShaderStageFlagBits stage, string fileContents, string shaderPrefix, string functionName)
        {
            int retVal = entrypoint.CreateShaderModule(stage);
            // GL.CreateShader(type);
            //string includePath = ".";

            // GLSL has this annoying feature that the #version directive must appear first. But we
            // want to inject some #define shenanigans into the shader.
            // So to do that, we need to split for the part of the shader up to the end of the #version line,
            // and everything after that. We can then inject our defines right there.
            var    strTuple       = VersionSplit(fileContents);
            string versionStr     = strTuple.Item1;
            string shaderContents = strTuple.Item2;

            var builder = new StringBuilder();

            builder.AppendLine(versionStr);
            builder.AppendLine(shaderPrefix);
            builder.Append(shaderContents);

            // APPEND custom function name to replicate custom function name
            builder.Append("void main() { ");
            builder.Append(functionName);
            builder.Append("(); }");

            entrypoint.CompileShaderModule(retVal, builder.ToString());

            //GL.ShaderSource(retVal, builder.ToString());
            //GL.CompileShader(retVal);

            bool isCompiled = entrypoint.IsCompiled(retVal);

            //int compileStatus = 0;
            //GL.GetShader(retVal, ShaderParameter.CompileStatus, out compileStatus);
            //// if (compileStatus != (int)All.True)

            //int glinfoLogLength = 0;
            //GL.GetShader(retVal, ShaderParameter.InfoLogLength, out glinfoLogLength);
            //if (glinfoLogLength > 1)

            bool hasMessages = entrypoint.HasCompilerMessages(retVal);

            if (hasMessages)
            {
                string buffer = entrypoint.GetCompilerMessages(retVal);
                //	GL.GetShaderInfoLog(retVal);
                if (!isCompiled)
                {
                    throw new Exception("Shader Compilation failed for shader with the following errors: " + buffer);
                }
                //				else {
                //					Console.WriteLine("Shader Compilation succeeded for shader '{0}', with the following log:", _shaderFilename);
                //				}
                //
                //				Console.WriteLine(buffer);
            }

            if (!isCompiled)
            {
                entrypoint.DeleteShaderModule(retVal);
                retVal = 0;
            }

            return(retVal);
        }
예제 #4
0
 public GLShaderModule(MgShaderModuleCreateInfo pCreateInfo, IGLShaderModuleEntrypoint entrypoint)
 {
     Info        = pCreateInfo;
     mEntrypoint = entrypoint;
 }