Example #1
0
 public PhysicalDeviceVulkan11Properties
 (
     StructureType sType    = StructureType.PhysicalDeviceVulkan11Properties,
     void *pNext            = default,
     uint deviceNodeMask    = default,
     Bool32 deviceLuidvalid = default,
     uint subgroupSize      = default,
     ShaderStageFlags subgroupSupportedStages         = default,
     SubgroupFeatureFlags subgroupSupportedOperations = default,
     Bool32 subgroupQuadOperationsInAllStages         = default,
     PointClippingBehavior pointClippingBehavior      = default,
     uint maxMultiviewViewCount     = default,
     uint maxMultiviewInstanceIndex = default,
     Bool32 protectedNoFault        = default,
     uint maxPerSetDescriptors      = default,
     ulong maxMemoryAllocationSize  = default
 )
 {
     SType                             = sType;
     PNext                             = pNext;
     DeviceNodeMask                    = deviceNodeMask;
     DeviceLuidvalid                   = deviceLuidvalid;
     SubgroupSize                      = subgroupSize;
     SubgroupSupportedStages           = subgroupSupportedStages;
     SubgroupSupportedOperations       = subgroupSupportedOperations;
     SubgroupQuadOperationsInAllStages = subgroupQuadOperationsInAllStages;
     PointClippingBehavior             = pointClippingBehavior;
     MaxMultiviewViewCount             = maxMultiviewViewCount;
     MaxMultiviewInstanceIndex         = maxMultiviewInstanceIndex;
     ProtectedNoFault                  = protectedNoFault;
     MaxPerSetDescriptors              = maxPerSetDescriptors;
     MaxMemoryAllocationSize           = maxMemoryAllocationSize;
 }
 public IndirectCommandsLayoutTokenNV
 (
     StructureType sType = StructureType.IndirectCommandsLayoutTokenNV,
     void *pNext         = default,
     IndirectCommandsTokenTypeNV tokenType = default,
     uint stream                = default,
     uint offset                = default,
     uint vertexBindingUnit     = default,
     Bool32 vertexDynamicStride = default,
     PipelineLayout pushconstantPipelineLayout     = default,
     ShaderStageFlags pushconstantShaderStageFlags = default,
     uint pushconstantOffset = default,
     uint pushconstantSize   = default,
     IndirectStateFlagsNV indirectStateFlags = default,
     uint indexTypeCount    = default,
     IndexType *pIndexTypes = default,
     uint *pIndexTypeValues = default
 )
 {
     SType                        = sType;
     PNext                        = pNext;
     TokenType                    = tokenType;
     Stream                       = stream;
     Offset                       = offset;
     VertexBindingUnit            = vertexBindingUnit;
     VertexDynamicStride          = vertexDynamicStride;
     PushconstantPipelineLayout   = pushconstantPipelineLayout;
     PushconstantShaderStageFlags = pushconstantShaderStageFlags;
     PushconstantOffset           = pushconstantOffset;
     PushconstantSize             = pushconstantSize;
     IndirectStateFlags           = indirectStateFlags;
     IndexTypeCount               = indexTypeCount;
     PIndexTypes                  = pIndexTypes;
     PIndexTypeValues             = pIndexTypeValues;
 }
Example #3
0
 public DescriptorInformation(uint binding, DescriptorType uniformBuffer, ShaderStageFlags myStage, uint descriptorCount)
 {
     this.ShaderStage = myStage;
     Binding          = binding;
     myType           = uniformBuffer;
     DescriptorCount  = descriptorCount;
 }
Example #4
0
        public unsafe Shader(Vk api, Device device, ShaderStage stage, ShaderBindings bindings, string glsl)
        {
            _api     = api;
            _device  = device;
            Bindings = bindings;

            glsl = glsl.Replace("gl_VertexID", "gl_VertexIndex");
            glsl = glsl.Replace("gl_InstanceID", "gl_InstanceIndex");
            glsl = glsl.Replace("gl_SubGroupInvocationARB", "gl_SubgroupInvocationID");
            glsl = glsl.Replace("unpackUint2x32(gl_SubGroupEqMaskARB).x", "gl_SubgroupEqMask.x");
            glsl = glsl.Replace("unpackUint2x32(gl_SubGroupGeMaskARB).x", "gl_SubgroupGeMask.x");
            glsl = glsl.Replace("unpackUint2x32(gl_SubGroupGtMaskARB).x", "gl_SubgroupGtMask.x");
            glsl = glsl.Replace("unpackUint2x32(gl_SubGroupLeMaskARB).x", "gl_SubgroupLeMask.x");
            glsl = glsl.Replace("unpackUint2x32(gl_SubGroupLtMaskARB).x", "gl_SubgroupLtMask.x");
            glsl = glsl.Replace("unpackUint2x32(ballotARB", "(subgroupBallot");
            glsl = glsl.Replace("readInvocationARB", "subgroupBroadcast");
            glsl = glsl.Replace("#extension GL_ARB_shader_ballot : enable", "#extension GL_KHR_shader_subgroup_basic : enable\n#extension GL_KHR_shader_subgroup_ballot : enable");

            // System.Console.WriteLine(glsl);

            Options options = new Options(false)
            {
                SourceLanguage     = SourceLanguage.Glsl,
                TargetSpirVVersion = new SpirVVersion(1, 5)
            };

            options.SetTargetEnvironment(TargetEnvironment.Vulkan, EnvironmentVersion.Vulkan_1_2);
            Compiler compiler = new Compiler(options);
            var      scr      = compiler.Compile(glsl, "Ryu", GetShaderCShaderStage(stage));

            if (scr.Status != Status.Success)
            {
                Logger.Error?.Print(LogClass.Gpu, $"Shader compilation error: {scr.Status} {scr.ErrorMessage}");
                return;
            }

            Valid = true;

            var spirvBytes = new Span <byte>((void *)scr.CodePointer, (int)scr.CodeLength);

            uint[] code = new uint[(scr.CodeLength + 3) / 4];

            spirvBytes.CopyTo(MemoryMarshal.Cast <uint, byte>(new Span <uint>(code)).Slice(0, (int)scr.CodeLength));

            fixed(uint *pCode = code)
            {
                var shaderModuleCreateInfo = new ShaderModuleCreateInfo()
                {
                    SType    = StructureType.ShaderModuleCreateInfo,
                    CodeSize = scr.CodeLength,
                    PCode    = pCode
                };

                api.CreateShaderModule(device, shaderModuleCreateInfo, null, out _module).ThrowOnError();
            }

            _stage          = stage.Convert();
            _entryPointName = Marshal.StringToHGlobalAnsi("main");
        }
 public Shader(string ShaderID, string EntryPoint, byte[] ShaderBytecode, ShaderStageFlags shaderType)
 {
     Descriptor          = new SubResourceSet(shaderType);
     EntryName           = EntryPoint;
     this.ShaderName     = ShaderID;
     this.ShaderBytecode = ShaderBytecode;
     ShaderStage         = shaderType;
 }
Example #6
0
 public PushConstantRange
 (
     ShaderStageFlags stageFlags = default,
     uint offset = default,
     uint size   = default
 )
 {
     StageFlags = stageFlags;
     Offset     = offset;
     Size       = size;
 }
Example #7
0
        private void InitEmbedded()
        {
            string codeWithComments = GetContentFromPath(FilePath);

            code = CommentRemover.GetCodeWithoutComments(codeWithComments);
            _segmentCollection = new SegmentCollection(code);
            string           extension   = Path.GetExtension(FilePath);
            ShaderStageFlags shaderStage = Constants.FileExtensionToShaderStageConverter.Convert(extension);

            ShaderStage = shaderStage;
        }
 public PhysicalDeviceCooperativeMatrixPropertiesNV
 (
     StructureType sType = StructureType.PhysicalDeviceCooperativeMatrixPropertiesNV,
     void *pNext         = default,
     ShaderStageFlags cooperativeMatrixSupportedStages = default
 )
 {
     SType = sType;
     PNext = pNext;
     CooperativeMatrixSupportedStages = cooperativeMatrixSupportedStages;
 }
 public PipelineExecutablePropertiesKHR
 (
     StructureType sType     = StructureType.PipelineExecutablePropertiesKhr,
     void *pNext             = default,
     ShaderStageFlags stages = default,
     uint subgroupSize       = default
 )
 {
     SType        = sType;
     PNext        = pNext;
     Stages       = stages;
     SubgroupSize = subgroupSize;
 }
Example #10
0
 public DescriptorSetLayoutBinding
 (
     uint binding = default,
     DescriptorType descriptorType = default,
     uint descriptorCount          = default,
     ShaderStageFlags stageFlags   = default,
     Sampler *pImmutableSamplers   = default
 )
 {
     Binding            = binding;
     DescriptorType     = descriptorType;
     DescriptorCount    = descriptorCount;
     StageFlags         = stageFlags;
     PImmutableSamplers = pImmutableSamplers;
 }
Example #11
0
 public PhysicalDeviceSubgroupSizeControlPropertiesEXT
 (
     StructureType sType  = StructureType.PhysicalDeviceSubgroupSizeControlPropertiesExt,
     void *pNext          = default,
     uint minSubgroupSize = default,
     uint maxSubgroupSize = default,
     uint maxComputeWorkgroupSubgroups           = default,
     ShaderStageFlags requiredSubgroupSizeStages = default
 )
 {
     SType           = sType;
     PNext           = pNext;
     MinSubgroupSize = minSubgroupSize;
     MaxSubgroupSize = maxSubgroupSize;
     MaxComputeWorkgroupSubgroups = maxComputeWorkgroupSubgroups;
     RequiredSubgroupSizeStages   = requiredSubgroupSizeStages;
 }
Example #12
0
 public PhysicalDeviceSubgroupProperties
 (
     StructureType sType = StructureType.PhysicalDeviceSubgroupProperties,
     void *pNext         = default,
     uint subgroupSize   = default,
     ShaderStageFlags supportedStages         = default,
     SubgroupFeatureFlags supportedOperations = default,
     Bool32 quadOperationsInAllStages         = default
 )
 {
     SType                     = sType;
     PNext                     = pNext;
     SubgroupSize              = subgroupSize;
     SupportedStages           = supportedStages;
     SupportedOperations       = supportedOperations;
     QuadOperationsInAllStages = quadOperationsInAllStages;
 }
Example #13
0
 public ShaderStatisticsInfoAMD
 (
     ShaderStageFlags shaderStageMask     = default,
     ShaderResourceUsageAMD resourceUsage = default,
     uint numPhysicalVgprs  = default,
     uint numPhysicalSgprs  = default,
     uint numAvailableVgprs = default,
     uint numAvailableSgprs = default
 )
 {
     ShaderStageMask   = shaderStageMask;
     ResourceUsage     = resourceUsage;
     NumPhysicalVgprs  = numPhysicalVgprs;
     NumPhysicalSgprs  = numPhysicalSgprs;
     NumAvailableVgprs = numAvailableVgprs;
     NumAvailableSgprs = numAvailableSgprs;
 }
 public PipelineShaderStageCreateInfo
 (
     StructureType sType = StructureType.PipelineShaderStageCreateInfo,
     void *pNext         = default,
     PipelineShaderStageCreateFlags flags = default,
     ShaderStageFlags stage = default,
     ShaderModule module    = default,
     byte *pName            = default,
     SpecializationInfo *pSpecializationInfo = default
 )
 {
     SType  = sType;
     PNext  = pNext;
     Flags  = flags;
     Stage  = stage;
     Module = module;
     PName  = pName;
     PSpecializationInfo = pSpecializationInfo;
 }
Example #15
0
        public unsafe Shader(Vk api, Device device, ShaderSource shaderSource)
        {
            _api     = api;
            _device  = device;
            Bindings = shaderSource.Bindings;

            CompileStatus = ProgramLinkStatus.Incomplete;

            _stage          = shaderSource.Stage.Convert();
            _entryPointName = Marshal.StringToHGlobalAnsi("main");

            CompileTask = Task.Run(() =>
            {
                byte[] spirv = shaderSource.BinaryCode;

                if (spirv == null)
                {
                    spirv = GlslToSpirv(shaderSource.Code, shaderSource.Stage);

                    if (spirv == null)
                    {
                        CompileStatus = ProgramLinkStatus.Failure;

                        return;
                    }
                }

                fixed(byte *pCode = spirv)
                {
                    var shaderModuleCreateInfo = new ShaderModuleCreateInfo()
                    {
                        SType    = StructureType.ShaderModuleCreateInfo,
                        CodeSize = (uint)spirv.Length,
                        PCode    = (uint *)pCode
                    };

                    api.CreateShaderModule(device, shaderModuleCreateInfo, null, out _module).ThrowOnError();
                }

                CompileStatus = ProgramLinkStatus.Success;
            });
        }
Example #16
0
        public unsafe Shader(Vk api, Device device, ShaderStage stage, ShaderBindings bindings, byte[] spirv)
        {
            _api     = api;
            _device  = device;
            Bindings = bindings;

            Valid = true;

            fixed(byte *pCode = spirv)
            {
                var shaderModuleCreateInfo = new ShaderModuleCreateInfo()
                {
                    SType    = StructureType.ShaderModuleCreateInfo,
                    CodeSize = (uint)spirv.Length,
                    PCode    = (uint *)pCode
                };

                api.CreateShaderModule(device, shaderModuleCreateInfo, null, out _module).ThrowOnError();
            }

            _stage          = stage.Convert();
            _entryPointName = Marshal.StringToHGlobalAnsi("main");
        }
Example #17
0
 public HardwareCapabilities(
     bool supportsIndexTypeUint8,
     bool supportsCustomBorderColor,
     bool supportsIndirectParameters,
     bool supportsFragmentShaderInterlock,
     bool supportsGeometryShaderPassthrough,
     bool supportsSubgroupSizeControl,
     bool supportsConditionalRendering,
     bool supportsExtendedDynamicState,
     bool supportsMultiView,
     bool supportsNullDescriptors,
     bool supportsPushDescriptors,
     bool supportsTransformFeedback,
     bool supportsTransformFeedbackQueries,
     bool supportsGeometryShader,
     uint minSubgroupSize,
     uint maxSubgroupSize,
     ShaderStageFlags requiredSubgroupSizeStages)
 {
     SupportsIndexTypeUint8            = supportsIndexTypeUint8;
     SupportsCustomBorderColor         = supportsCustomBorderColor;
     SupportsIndirectParameters        = supportsIndirectParameters;
     SupportsFragmentShaderInterlock   = supportsFragmentShaderInterlock;
     SupportsGeometryShaderPassthrough = supportsGeometryShaderPassthrough;
     SupportsSubgroupSizeControl       = supportsSubgroupSizeControl;
     SupportsConditionalRendering      = supportsConditionalRendering;
     SupportsExtendedDynamicState      = supportsExtendedDynamicState;
     SupportsMultiView                = supportsMultiView;
     SupportsNullDescriptors          = supportsNullDescriptors;
     SupportsPushDescriptors          = supportsPushDescriptors;
     SupportsTransformFeedback        = supportsTransformFeedback;
     SupportsTransformFeedbackQueries = supportsTransformFeedbackQueries;
     SupportsGeometryShader           = supportsGeometryShader;
     MinSubgroupSize            = minSubgroupSize;
     MaxSubgroupSize            = maxSubgroupSize;
     RequiredSubgroupSizeStages = requiredSubgroupSizeStages;
 }
Example #18
0
 public abstract Result GetShaderInfo <T0>([Count(Count = 0)] Device device, [Count(Count = 0)] Pipeline pipeline, [Count(Count = 0)] ShaderStageFlags shaderStage, [Count(Count = 0)] ShaderInfoTypeAMD infoType, [Count(Count = 0)] ref UIntPtr pInfoSize, [Count(Computed = "pInfoSize")] ref T0 pInfo) where T0 : unmanaged;
Example #19
0
 public abstract unsafe Result GetShaderInfo([Count(Count = 0)] Device device, [Count(Count = 0)] Pipeline pipeline, [Count(Count = 0)] ShaderStageFlags shaderStage, [Count(Count = 0)] ShaderInfoTypeAMD infoType, [Count(Count = 0)] UIntPtr *pInfoSize, [Count(Computed = "pInfoSize")] void *pInfo);
 public static extern void vkCmdPushConstants(IntPtr commandBuffer, ulong layout, ShaderStageFlags stageFlags, uint offset, uint size, IntPtr pValues);
Example #21
0
 public SubResourceSet(ShaderStageFlags myStage)
 {
     this.ShaderStage      = myStage;
     myDescriptorTypeCount = new uint[Enum.GetValues(typeof(DescriptorType)).Length];
 }
Example #22
0
 /// <param name="Stage">Shader stage</param>
 /// <param name="Module">Module containing entry point</param>
 /// <param name="Name">Null-terminated entry point name</param>
 public PipelineShaderStageCreateInfo(ShaderStageFlags Stage, ShaderModule Module, String Name) : this()
 {
     this.Stage  = Stage;
     this.Module = Module;
     this.Name   = Name;
 }
Example #23
0
 /// <summary>To be documented.</summary>
 public static unsafe Result GetShaderInfo <T0>(this AmdShaderInfo thisApi, [Count(Count = 0)] Device device, [Count(Count = 0)] Pipeline pipeline, [Count(Count = 0)] ShaderStageFlags shaderStage, [Count(Count = 0)] ShaderInfoTypeAMD infoType, [Count(Count = 0)] Span <UIntPtr> pInfoSize, [Count(Computed = "pInfoSize")] Span <T0> pInfo) where T0 : unmanaged
 {
     // SpanOverloader
     return(thisApi.GetShaderInfo(device, pipeline, shaderStage, infoType, ref pInfoSize.GetPinnableReference(), ref pInfo.GetPinnableReference()));
 }
Example #24
0
 internal static unsafe extern void vkCmdPushConstants(CommandBuffer commandBuffer, PipelineLayout layout, ShaderStageFlags stageFlags, uint offset, uint size, IntPtr values);
Example #25
0
 internal static unsafe extern void vkCmdPushConstants(CommandBuffer commandBuffer, PipelineLayout layout, ShaderStageFlags stageFlags, UInt32 offset, UInt32 size, IntPtr Values);
Example #26
0
 internal static unsafe extern void vkCmdPushConstants(IntPtr commandBuffer, UInt64 layout, ShaderStageFlags stageFlags, UInt32 offset, UInt32 size, IntPtr pValues);
Example #27
0
 public unsafe partial Result GetShaderInfo([Count(Count = 0)] Device device, [Count(Count = 0)] Pipeline pipeline, [Count(Count = 0)] ShaderStageFlags shaderStage, [Count(Count = 0)] ShaderInfoTypeAMD infoType, [Count(Count = 0)] ref nuint pInfoSize, [Count(Computed = "pInfoSize")] void *pInfo);
Example #28
0
 /// <summary>
 ///
 /// </summary>
 public PushConstantRange(ShaderStageFlags stageFlags, uint offset, uint size)
 {
     this.StageFlags = stageFlags;
     this.Offset     = offset;
     this.Size       = size;
 }
Example #29
0
 public partial Result GetShaderInfo <T0>([Count(Count = 0)] Device device, [Count(Count = 0)] Pipeline pipeline, [Count(Count = 0)] ShaderStageFlags shaderStage, [Count(Count = 0)] ShaderInfoTypeAMD infoType, [Count(Count = 0)] ref nuint pInfoSize, [Count(Computed = "pInfoSize")] ref T0 pInfo) where T0 : unmanaged;
Example #30
0
 /// <summary>To be documented.</summary>
 public static unsafe Result GetShaderInfo(this AmdShaderInfo thisApi, [Count(Count = 0)] Device device, [Count(Count = 0)] Pipeline pipeline, [Count(Count = 0)] ShaderStageFlags shaderStage, [Count(Count = 0)] ShaderInfoTypeAMD infoType, [Count(Count = 0)] Span <nuint> pInfoSize, [Count(Parameter = "pInfoSize")] void *pInfo)
 {
     // SpanOverloader
     return(thisApi.GetShaderInfo(device, pipeline, shaderStage, infoType, ref pInfoSize.GetPinnableReference(), pInfo));
 }
Example #31
0
 public unsafe void PushConstants(PipelineLayout layout, ShaderStageFlags stageFlags, uint offset, uint size, IntPtr values)
 {
     vkCmdPushConstants(this, layout, stageFlags, offset, size, values);
 }
Example #32
0
 public DescriptorBinding(uint binding, uint descriptorCount, DescriptorType type, ShaderStageFlags stage) =>
 (Binding, DescriptorCount, Type, Stage) = (binding, descriptorCount, type, stage);