summaryrefslogtreecommitdiffstats
path: root/src/libs/dxvk-native-1.9.2a/src/dxvk/dxvk_meta_clear.h
blob: eaf12adee9131bca73c5c43296382288099cf2a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once

#include "dxvk_format.h"
#include "dxvk_include.h"

#include "../spirv/spirv_code_buffer.h"

namespace dxvk {

  class DxvkDevice;
  
  /**
   * \brief Clear args
   * 
   * The data structure that can be passed
   * to the clear shaders as push constants.
   */
  struct DxvkMetaClearArgs {
    VkClearColorValue clearValue;
    VkOffset3D offset; uint32_t pad1;
    VkExtent3D extent; uint32_t pad2;
  };
  
  
  /**
   * \brief Pipeline-related objects
   * 
   * Use this to bind the pipeline
   * and allocate a descriptor set.
   */
  struct DxvkMetaClearPipeline {
    VkDescriptorSetLayout dsetLayout;
    VkPipelineLayout      pipeLayout;
    VkPipeline            pipeline;
    VkExtent3D            workgroupSize;
  };
  
  
  /**
   * \brief Clear shaders and related objects
   * 
   * Creates the shaders, pipeline layouts, and
   * compute pipelines that are going to be used
   * for clear operations.
   */
  class DxvkMetaClearObjects {
    
  public:
    
    DxvkMetaClearObjects(const DxvkDevice* device);
    ~DxvkMetaClearObjects();
    
    /**
     * \brief Retrieves objects to use for buffers
     * 
     * Returns the pipeline, pipeline layout and descriptor
     * set layout which are required to perform a meta clear
     * operation on a buffer resource with the given format.
     * \param [in] viewType The image virw type
     */
    DxvkMetaClearPipeline getClearBufferPipeline(
            DxvkFormatFlags       formatFlags) const;
    
    /**
     * \brief Retrieves objects for a given image view type
     * 
     * Returns the pipeline, pipeline layout and descriptor
     * set layout which are required to perform a meta clear
     * operation on a resource with the given view type.
     * \param [in] viewType The image virw type
     * \returns The pipeline-related objects to use
     */
    DxvkMetaClearPipeline getClearImagePipeline(
            VkImageViewType       viewType,
            DxvkFormatFlags       formatFlags) const;
    
  private:
    
    struct DxvkMetaClearPipelines {
      VkPipeline clearBuf        = VK_NULL_HANDLE;
      VkPipeline clearImg1D      = VK_NULL_HANDLE;
      VkPipeline clearImg2D      = VK_NULL_HANDLE;
      VkPipeline clearImg3D      = VK_NULL_HANDLE;
      VkPipeline clearImg1DArray = VK_NULL_HANDLE;
      VkPipeline clearImg2DArray = VK_NULL_HANDLE;
    };
    
    Rc<vk::DeviceFn> m_vkd;
    
    VkDescriptorSetLayout m_clearBufDsetLayout = VK_NULL_HANDLE;
    VkDescriptorSetLayout m_clearImgDsetLayout = VK_NULL_HANDLE;
    
    VkPipelineLayout m_clearBufPipeLayout = VK_NULL_HANDLE;
    VkPipelineLayout m_clearImgPipeLayout = VK_NULL_HANDLE;
    
    DxvkMetaClearPipelines m_clearPipesF32;
    DxvkMetaClearPipelines m_clearPipesU32;
    
    VkDescriptorSetLayout createDescriptorSetLayout(
            VkDescriptorType        descriptorType);
    
    VkPipelineLayout createPipelineLayout(
            VkDescriptorSetLayout   dsetLayout);
    
    VkPipeline createPipeline(
      const SpirvCodeBuffer&        spirvCode,
            VkPipelineLayout        pipeLayout);
    
  };
  
}