예제 #1
0
        void setupDescriptorSet()
        {
            var dsl = descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &dsl,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSet));

            VkDescriptorImageInfo texDescriptor =
                Initializers.descriptorImageInfo(
                    textures_colorMap.sampler,
                    textures_colorMap.view,
                    VkImageLayout.General);

            var temp = uniformBuffers_scene.descriptor;
            FixedArray2 <VkWriteDescriptorSet> writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>(
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSet,
                    VkDescriptorType.UniformBuffer,
                    0,
                    &temp),
                // Binding 1 : Color map
                Initializers.writeDescriptorSet(
                    descriptorSet,
                    VkDescriptorType.CombinedImageSampler,
                    1,
                    &texDescriptor));

            vkUpdateDescriptorSets(device, (writeDescriptorSets.Count), ref writeDescriptorSets.First, 0, null);
        }
예제 #2
0
        void setupDescriptorSets()
        {
            // Image descriptor for the cube map texture
            VkDescriptorImageInfo textureDescriptor =
                Initializers.descriptorImageInfo(
                    cubeMap.sampler,
                    cubeMap.view,
                    cubeMap.imageLayout);

            var dsl = descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &dsl,
                    1);

            // 3D object descriptor set
            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSets_object));

            var bufferInfo = uniformBuffers_object.descriptor;
            FixedArray2 <VkWriteDescriptorSet> writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>
                                                                     (
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_object,
                    VkDescriptorType.UniformBuffer,
                    0,
                    &bufferInfo),
                // Binding 1 : Fragment shader cubemap sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_object,
                    VkDescriptorType.CombinedImageSampler,
                    1,
                    &textureDescriptor));

            vkUpdateDescriptorSets(device, writeDescriptorSets.Count, ref writeDescriptorSets.First, 0, null);

            // Sky box descriptor set
            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSets_skybox));

            var descriptor = uniformBuffers_skybox.descriptor;

            writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>
                                  (
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_skybox,
                    VkDescriptorType.UniformBuffer,
                    0,
                    &descriptor),
                // Binding 1 : Fragment shader cubemap sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_skybox,
                    VkDescriptorType.CombinedImageSampler,
                    1,
                    &textureDescriptor));

            vkUpdateDescriptorSets(device, writeDescriptorSets.Count, ref writeDescriptorSets.First, 0, null);
        }
예제 #3
0
        void setupDescriptorSet()
        {
            VkDescriptorSetAllocateInfo descriptorSetAllocInfo;

            // Scene rendering
            var dsl = descriptorSetLayouts_scene;

            descriptorSetAllocInfo = Initializers.descriptorSetAllocateInfo(descriptorPool, &dsl, 1);
            Util.CheckResult(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, out descriptorSets_scene));

            var descriptor0 = uniformBuffers_scene.descriptor;
            var descriptor1 = textures_gradient.descriptor;
            NativeList <VkWriteDescriptorSet> offScreenWriteDescriptorSets = new NativeList <VkWriteDescriptorSet>
            {
                // Binding 0: Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_scene,
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    0,
                    &descriptor0),
                // Binding 1: Color gradient sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_scene,
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    1,
                    &descriptor1),
            };

            vkUpdateDescriptorSets(device, offScreenWriteDescriptorSets.Count, offScreenWriteDescriptorSets.Data, 0, null);

            // Fullscreen radial blur
            dsl = descriptorSetLayouts_radialBlur;
            descriptorSetAllocInfo = Initializers.descriptorSetAllocateInfo(descriptorPool, &dsl, 1);
            Util.CheckResult(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, out descriptorSets_radialBlur));

            descriptor0 = uniformBuffers_blurParams.descriptor;
            descriptor1 = offscreenPass.descriptor;
            NativeList <VkWriteDescriptorSet> writeDescriptorSets = new NativeList <VkWriteDescriptorSet>
            {
                // Binding 0: Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_radialBlur,
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    0,
                    &descriptor0),
                // Binding 0: Fragment shader texture sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_radialBlur,
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    1,
                    &descriptor1),
            };

            vkUpdateDescriptorSets(device, writeDescriptorSets.Count, writeDescriptorSets.Data, 0, null);
        }
        void setupDescriptorSet()
        {
            var dsl = descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &dsl,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSet));

            var descriptor1 = uniformBuffer.descriptor;
            var descriptor2 = textures_colormap.descriptor;
            FixedArray2 <VkWriteDescriptorSet> writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>(
                Initializers.writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &descriptor1),
                Initializers.writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &descriptor2));

            vkUpdateDescriptorSets(device, (uint)(writeDescriptorSets.Count), &writeDescriptorSets.First, 0, null);
        }
        void setupDescriptorSet()
        {
            var dsl = descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &dsl,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSet));

            var descriptor0 = uniformBuffers_view.descriptor;
            var descriptor1 = uniformBuffers_dynamic.descriptor;
            FixedArray2 <VkWriteDescriptorSet> writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>(
                // Binding 0 : Projection/View matrix uniform buffer
                Initializers.writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &descriptor0),
                // Binding 1 : Instance matrix as dynamic uniform buffer
                Initializers.writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, &descriptor1));

            vkUpdateDescriptorSets(device, writeDescriptorSets.Count, &writeDescriptorSets.First, 0, null);
        }
예제 #6
0
        void setupDescriptorSet()
        {
            var dsl = descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &dsl,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSet));

            var descriptor = uniformBuffer.descriptor;
            // Binding 0 : Vertex shader uniform buffer
            VkWriteDescriptorSet writeDescriptorSet =
                Initializers.writeDescriptorSet(
                    descriptorSet,
                    VkDescriptorType.UniformBuffer,
                    0,
                    &descriptor);

            vkUpdateDescriptorSets(device, 1, &writeDescriptorSet, 0, null);
        }
예제 #7
0
        void setupDescriptorSet()
        {
            var layout = descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &layout,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSet));

            // Setup a descriptor image info for the current texture to be used as a combined image sampler
            VkDescriptorImageInfo textureDescriptor;

            textureDescriptor.imageView   = texture.view;           // The image's view (images are never directly accessed by the shader, but rather through views defining subresources)
            textureDescriptor.sampler     = texture.sampler;        //	The sampler (Telling the pipeline how to sample the texture, including repeat, border, etc.)
            textureDescriptor.imageLayout = texture.imageLayout;    //	The current layout of the image (Note: Should always fit the actual use, e.g. shader read)

            var descriptor = uniformBufferVS.descriptor;
            FixedArray2 <VkWriteDescriptorSet> writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>(
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSet,
                    VkDescriptorType.UniformBuffer,
                    0,
                    &descriptor),
                // Binding 1 : Fragment shader texture sampler
                //	Fragment shader: layout (binding = 1) uniform sampler2D samplerColor;
                Initializers.writeDescriptorSet(
                    descriptorSet,
                    VkDescriptorType.CombinedImageSampler,              // The descriptor set will use a combined image sampler (sampler and image could be split)
                    1,                                                  // Shader binding point 1
                    &textureDescriptor)                                 // Pointer to the descriptor image for our texture
                );

            vkUpdateDescriptorSets(device, writeDescriptorSets.Count, ref writeDescriptorSets.First, 0, null);
        }
예제 #8
0
        void setupDescriptorSet()
        {
            var dsl = descriptorSetLayouts_textured;
            // Mirror plane descriptor set
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    descriptorPool,
                    &dsl,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSets_mirror));

            var descriptor0 = uniformBuffers_vsMirror.descriptor;
            var descriptor1 = offscreenPass.descriptor;
            var descriptor2 = textures_colorMap.descriptor;
            FixedArray3<VkWriteDescriptorSet> writeDescriptorSets = new FixedArray3<VkWriteDescriptorSet>(
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_mirror,
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    0,
                    &descriptor0),
                // Binding 1 : Fragment shader texture sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_mirror,
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    1,
                    &descriptor1),
                // Binding 2 : Fragment shader texture sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_mirror,
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    2,
                    &descriptor2));

            vkUpdateDescriptorSets(device, writeDescriptorSets.Count, &writeDescriptorSets.First, 0, null);

            // Debug quad
            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSets_debugQuad));

            var descriptor3 = uniformBuffers_vsDebugQuad.descriptor;
            var descriptor4 = offscreenPass.descriptor;
            FixedArray2<VkWriteDescriptorSet> debugQuadWriteDescriptorSets = new FixedArray2<VkWriteDescriptorSet>(
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_debugQuad,
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    0,
                    &descriptor3),
                // Binding 1 : Fragment shader texture sampler
                Initializers.writeDescriptorSet(
                    descriptorSets_debugQuad,
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    1,
                    &descriptor4));

            vkUpdateDescriptorSets(device, debugQuadWriteDescriptorSets.Count, &debugQuadWriteDescriptorSets.First, 0, null);

            var dsls_shaded = descriptorSetLayouts_shaded;
            // Shaded descriptor sets
            allocInfo.pSetLayouts = &dsls_shaded;

            // Model
            // No texture
            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSets_model));

            var descriptor5 = uniformBuffers_vsShared.descriptor;
            VkWriteDescriptorSet modelWriteDescriptorSets =
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    descriptorSets_model,
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    0,
                    &descriptor5);
            vkUpdateDescriptorSets(device, 1, &modelWriteDescriptorSets, 0, null);

            // Offscreen
            Util.CheckResult(vkAllocateDescriptorSets(device, &allocInfo, out descriptorSets_offscreen));

            var descriptor6 = uniformBuffers_vsOffScreen.descriptor;
            VkWriteDescriptorSet offScreenWriteDescriptorSets =
            // Binding 0 : Vertex shader uniform buffer
            Initializers.writeDescriptorSet(
                descriptorSets_offscreen,
                VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                0,
                &descriptor6);

            vkUpdateDescriptorSets(device, 1, &offScreenWriteDescriptorSets, 0, null);
        }