Exemplo n.º 1
0
        /// <summary>
        /// To be added.
        /// </summary>
        /// <param name="shader">
        /// To be added.
        /// </param>
        /// <param name="count">
        /// To be added.
        /// </param>
        /// <param name="path">
        /// To be added.
        /// This parameter's element count is taken from count.
        /// </param>
        /// <param name="length">
        /// To be added.
        /// This parameter's element count is taken from count.
        /// </param>
        public unsafe void CompileShaderInclude([Flow(FlowDirection.In)] uint shader, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] string[] pathSa, [Count(Parameter = "count"), Flow(FlowDirection.In)] Span <int> length)
        {
            // StringArrayOverloader
            var path = (char **)SilkMarshal.MarshalStringArrayToPtr(pathSa);

            CompileShaderInclude(shader, count, path, length);
            SilkMarshal.CopyPtrToStringArray((IntPtr)path, pathSa);
        }
        /// <summary>
        /// To be added.
        /// </summary>
        /// <param name="program">
        /// To be added.
        /// </param>
        /// <param name="uniformCount">
        /// To be added.
        /// </param>
        /// <param name="uniformNames">
        /// To be added.
        /// This parameter's element count is computed from uniformCount.
        /// </param>
        /// <param name="uniformIndices">
        /// To be added.
        /// This parameter's element count is computed from uniformCount.
        /// </param>
        public unsafe void GetUniformIndices([Flow(FlowDirection.In)] uint program, [Flow(FlowDirection.In)] uint uniformCount, [Count(Computed = "uniformCount"), Flow(FlowDirection.In)] string[] uniformNamesSa, [Count(Computed = "uniformCount"), Flow(FlowDirection.Out)] uint *uniformIndices)
        {
            // StringArrayOverloader
            var uniformNames = (char **)SilkMarshal.MarshalStringArrayToPtr(uniformNamesSa);

            GetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
            SilkMarshal.CopyPtrToStringArray((IntPtr)uniformNames, uniformNamesSa);
        }
Exemplo n.º 3
0
        /// <summary>
        /// To be added.
        /// </summary>
        /// <param name="program">
        /// To be added.
        /// </param>
        /// <param name="count">
        /// To be added.
        /// </param>
        /// <param name="varyings">
        /// To be added.
        /// This parameter's element count is taken from count.
        /// </param>
        /// <param name="bufferMode">
        /// To be added.
        /// </param>
        public unsafe void TransformFeedbackVaryings([Flow(FlowDirection.In)] uint program, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] string[] varyingsSa, [Flow(FlowDirection.In)] EXT bufferMode)
        {
            // StringArrayOverloader
            var varyings = (char **)SilkMarshal.MarshalStringArrayToPtr(varyingsSa);

            TransformFeedbackVaryings(program, count, varyings, bufferMode);
            SilkMarshal.CopyPtrToStringArray((IntPtr)varyings, varyingsSa);
        }
Exemplo n.º 4
0
        /// <summary>
        /// To be added.
        /// </summary>
        /// <param name="shaderObj">
        /// To be added.
        /// </param>
        /// <param name="count">
        /// To be added.
        /// </param>
        /// <param name="@string">
        /// To be added.
        /// This parameter's element count is taken from count.
        /// </param>
        /// <param name="length">
        /// To be added.
        /// This parameter's element count is taken from count.
        /// </param>
        public unsafe void ShaderSource([Flow(FlowDirection.In)] uint shaderObj, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] string[] @stringSa, [Count(Parameter = "count"), Flow(FlowDirection.In)] Span <int> length)
        {
            // StringArrayOverloader
            var @string = (char **)SilkMarshal.MarshalStringArrayToPtr(@stringSa);

            ShaderSource(shaderObj, count, @string, length);
            SilkMarshal.CopyPtrToStringArray((IntPtr)@string, @stringSa);
        }
Exemplo n.º 5
0
        /// <summary>
        /// To be added.
        /// </summary>
        /// <param name="type">
        /// To be added.
        /// </param>
        /// <param name="count">
        /// To be added.
        /// </param>
        /// <param name="strings">
        /// To be added.
        /// This parameter's element count is taken from count.
        /// </param>
        /// <returns>See summary.</returns>
        public unsafe uint CreateShaderProgram([Flow(FlowDirection.In)] ShaderType type, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] string[] stringsSa)
        {
            // StringArrayOverloader
            var strings = (char **)SilkMarshal.MarshalStringArrayToPtr(stringsSa);
            var ret     = CreateShaderProgram(type, count, strings);

            SilkMarshal.CopyPtrToStringArray((IntPtr)strings, stringsSa);
            return(ret);
        }
Exemplo n.º 6
0
        private unsafe void CreateInstance()
        {
            _vk = Vk.GetApi();

            if (EnableValidationLayers && !CheckValidationLayerSupport())
            {
                throw new NotSupportedException("Validation layers requested but not available!");
            }

            var appInfo = new ApplicationInfo
            {
                SType              = StructureType.ApplicationInfo,
                PApplicationName   = (byte *)Marshal.StringToHGlobalAnsi("Hello Triangle"),
                ApplicationVersion = Vk.MakeVersion(1, 0),
                PEngineName        = (byte *)Marshal.StringToHGlobalAnsi("No Engine"),
                EngineVersion      = Vk.MakeVersion(1, 0),
                ApiVersion         = Vk.Version11
            };

            var    extensions    = (byte **)_window.VkSurface.GetRequiredExtensions(out var extCount);
            byte **newExtensions = stackalloc byte *[(int)(extCount + _instanceExtensions.Length)];

            for (int i = 0; i < extCount; i++)
            {
                newExtensions[i] = extensions[i];
            }

            for (var i = 0; i < _instanceExtensions.Length; i++)
            {
                newExtensions[extCount + i] = (byte *)SilkMarshal.MarshalStringToPtr(_instanceExtensions[i]);
            }

            extCount += (uint)_instanceExtensions.Length;

            var createInfo = new InstanceCreateInfo
            {
                SType                   = StructureType.InstanceCreateInfo,
                PApplicationInfo        = &appInfo,
                EnabledExtensionCount   = extCount,
                PpEnabledExtensionNames = newExtensions
            };

            // debug info is here to make sure it doesnt get destroyed before vk.CreateInstance
            var debugCreateInfo = new DebugUtilsMessengerCreateInfoEXT();

            if (EnableValidationLayers)
            {
                createInfo.EnabledLayerCount   = (uint)_validationLayers.Length;
                createInfo.PpEnabledLayerNames = (byte **)SilkMarshal.MarshalStringArrayToPtr(_validationLayers);
                createInfo.PNext = &debugCreateInfo;
            }
            else
            {
                createInfo.EnabledLayerCount = 0;
                createInfo.PNext             = null;
            }

            fixed(Instance *instance = &_instance)
            {
                Result result = _vk.CreateInstance(&createInfo, null, instance);

                if (result != Result.Success)
                {
                    throw new Exception("Failed to create instance!");
                }
            }

            _vk.CurrentInstance = _instance;

            if (!_vk.TryGetInstanceExtension(_instance, out _vkSurface))
            {
                throw new NotSupportedException("KHR_surface extensions not found");
            }
        }
Exemplo n.º 7
0
        private unsafe void CreateLogicalDevice()
        {
            QueueFamilyIndices indices = FindQueueFamilies(_physicalDevice);

            uint[] uniqueQueueFamilies = new[] { indices.GraphicsFamily.Value, indices.PresentFamily.Value };
            var    queueCreateInfos    = stackalloc DeviceQueueCreateInfo[uniqueQueueFamilies.Length];

            float queuePriority = 1.0f;

            for (int i = 0; i < uniqueQueueFamilies.Length; i++)
            {
                uint queueFamily     = uniqueQueueFamilies[i];
                var  queueCreateInfo = new DeviceQueueCreateInfo
                {
                    SType            = StructureType.DeviceQueueCreateInfo,
                    QueueFamilyIndex = queueFamily,
                    QueueCount       = 1,
                    PQueuePriorities = &queuePriority
                };
                queueCreateInfos[i] = queueCreateInfo;
            }

            var deviceFeatures = new PhysicalDeviceFeatures();

            var createInfo = new DeviceCreateInfo
            {
                SType                 = StructureType.DeviceCreateInfo,
                PQueueCreateInfos     = queueCreateInfos,
                QueueCreateInfoCount  = (uint)uniqueQueueFamilies.Length,
                PEnabledFeatures      = &deviceFeatures,
                EnabledExtensionCount = 0
            };

            if (EnableValidationLayers)
            {
                createInfo.EnabledLayerCount   = (uint)_validationLayers.Length;
                createInfo.PpEnabledLayerNames = (byte **)SilkMarshal.MarshalStringArrayToPtr(_validationLayers);
            }
            else
            {
                createInfo.EnabledLayerCount = 0;
            }

            fixed(Device *device = &_device)
            {
                Result result = _vk.CreateDevice(_physicalDevice, &createInfo, (AllocationCallbacks *)null, device);

                if (result != Result.Success)
                {
                    throw new Exception("Failed to create logical device!");
                }
            }

            fixed(Queue *graphicsQueue = &_graphicsQueue)
            {
                _vk.GetDeviceQueue(_device, indices.GraphicsFamily.Value, 0, graphicsQueue);
            }

            fixed(Queue *presentQueue = &_presentQueue)
            {
                _vk.GetDeviceQueue(_device, indices.PresentFamily.Value, 0, presentQueue);
            }
        }