diff options
Diffstat (limited to 'src/shader_recompiler/shader_info.h')
| -rw-r--r-- | src/shader_recompiler/shader_info.h | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h new file mode 100644 index 000000000..4ef4dbd40 --- /dev/null +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -0,0 +1,193 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <bitset> | ||
| 9 | |||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "shader_recompiler/frontend/ir/type.h" | ||
| 12 | #include "shader_recompiler/varying_state.h" | ||
| 13 | |||
| 14 | #include <boost/container/small_vector.hpp> | ||
| 15 | #include <boost/container/static_vector.hpp> | ||
| 16 | |||
| 17 | namespace Shader { | ||
| 18 | |||
| 19 | enum class TextureType : u32 { | ||
| 20 | Color1D, | ||
| 21 | ColorArray1D, | ||
| 22 | Color2D, | ||
| 23 | ColorArray2D, | ||
| 24 | Color3D, | ||
| 25 | ColorCube, | ||
| 26 | ColorArrayCube, | ||
| 27 | Buffer, | ||
| 28 | }; | ||
| 29 | constexpr u32 NUM_TEXTURE_TYPES = 8; | ||
| 30 | |||
| 31 | enum class ImageFormat : u32 { | ||
| 32 | Typeless, | ||
| 33 | R8_UINT, | ||
| 34 | R8_SINT, | ||
| 35 | R16_UINT, | ||
| 36 | R16_SINT, | ||
| 37 | R32_UINT, | ||
| 38 | R32G32_UINT, | ||
| 39 | R32G32B32A32_UINT, | ||
| 40 | }; | ||
| 41 | |||
| 42 | enum class Interpolation { | ||
| 43 | Smooth, | ||
| 44 | Flat, | ||
| 45 | NoPerspective, | ||
| 46 | }; | ||
| 47 | |||
| 48 | struct ConstantBufferDescriptor { | ||
| 49 | u32 index; | ||
| 50 | u32 count; | ||
| 51 | }; | ||
| 52 | |||
| 53 | struct StorageBufferDescriptor { | ||
| 54 | u32 cbuf_index; | ||
| 55 | u32 cbuf_offset; | ||
| 56 | u32 count; | ||
| 57 | bool is_written; | ||
| 58 | }; | ||
| 59 | |||
| 60 | struct TextureBufferDescriptor { | ||
| 61 | bool has_secondary; | ||
| 62 | u32 cbuf_index; | ||
| 63 | u32 cbuf_offset; | ||
| 64 | u32 secondary_cbuf_index; | ||
| 65 | u32 secondary_cbuf_offset; | ||
| 66 | u32 count; | ||
| 67 | u32 size_shift; | ||
| 68 | }; | ||
| 69 | using TextureBufferDescriptors = boost::container::small_vector<TextureBufferDescriptor, 6>; | ||
| 70 | |||
| 71 | struct ImageBufferDescriptor { | ||
| 72 | ImageFormat format; | ||
| 73 | bool is_written; | ||
| 74 | bool is_read; | ||
| 75 | u32 cbuf_index; | ||
| 76 | u32 cbuf_offset; | ||
| 77 | u32 count; | ||
| 78 | u32 size_shift; | ||
| 79 | }; | ||
| 80 | using ImageBufferDescriptors = boost::container::small_vector<ImageBufferDescriptor, 2>; | ||
| 81 | |||
| 82 | struct TextureDescriptor { | ||
| 83 | TextureType type; | ||
| 84 | bool is_depth; | ||
| 85 | bool has_secondary; | ||
| 86 | u32 cbuf_index; | ||
| 87 | u32 cbuf_offset; | ||
| 88 | u32 secondary_cbuf_index; | ||
| 89 | u32 secondary_cbuf_offset; | ||
| 90 | u32 count; | ||
| 91 | u32 size_shift; | ||
| 92 | }; | ||
| 93 | using TextureDescriptors = boost::container::small_vector<TextureDescriptor, 12>; | ||
| 94 | |||
| 95 | struct ImageDescriptor { | ||
| 96 | TextureType type; | ||
| 97 | ImageFormat format; | ||
| 98 | bool is_written; | ||
| 99 | bool is_read; | ||
| 100 | u32 cbuf_index; | ||
| 101 | u32 cbuf_offset; | ||
| 102 | u32 count; | ||
| 103 | u32 size_shift; | ||
| 104 | }; | ||
| 105 | using ImageDescriptors = boost::container::small_vector<ImageDescriptor, 4>; | ||
| 106 | |||
| 107 | struct Info { | ||
| 108 | static constexpr size_t MAX_CBUFS{18}; | ||
| 109 | static constexpr size_t MAX_SSBOS{32}; | ||
| 110 | |||
| 111 | bool uses_workgroup_id{}; | ||
| 112 | bool uses_local_invocation_id{}; | ||
| 113 | bool uses_invocation_id{}; | ||
| 114 | bool uses_sample_id{}; | ||
| 115 | bool uses_is_helper_invocation{}; | ||
| 116 | bool uses_subgroup_invocation_id{}; | ||
| 117 | bool uses_subgroup_shuffles{}; | ||
| 118 | std::array<bool, 30> uses_patches{}; | ||
| 119 | |||
| 120 | std::array<Interpolation, 32> interpolation{}; | ||
| 121 | VaryingState loads; | ||
| 122 | VaryingState stores; | ||
| 123 | VaryingState passthrough; | ||
| 124 | |||
| 125 | bool loads_indexed_attributes{}; | ||
| 126 | |||
| 127 | std::array<bool, 8> stores_frag_color{}; | ||
| 128 | bool stores_sample_mask{}; | ||
| 129 | bool stores_frag_depth{}; | ||
| 130 | |||
| 131 | bool stores_tess_level_outer{}; | ||
| 132 | bool stores_tess_level_inner{}; | ||
| 133 | |||
| 134 | bool stores_indexed_attributes{}; | ||
| 135 | |||
| 136 | bool stores_global_memory{}; | ||
| 137 | |||
| 138 | bool uses_fp16{}; | ||
| 139 | bool uses_fp64{}; | ||
| 140 | bool uses_fp16_denorms_flush{}; | ||
| 141 | bool uses_fp16_denorms_preserve{}; | ||
| 142 | bool uses_fp32_denorms_flush{}; | ||
| 143 | bool uses_fp32_denorms_preserve{}; | ||
| 144 | bool uses_int8{}; | ||
| 145 | bool uses_int16{}; | ||
| 146 | bool uses_int64{}; | ||
| 147 | bool uses_image_1d{}; | ||
| 148 | bool uses_sampled_1d{}; | ||
| 149 | bool uses_sparse_residency{}; | ||
| 150 | bool uses_demote_to_helper_invocation{}; | ||
| 151 | bool uses_subgroup_vote{}; | ||
| 152 | bool uses_subgroup_mask{}; | ||
| 153 | bool uses_fswzadd{}; | ||
| 154 | bool uses_derivatives{}; | ||
| 155 | bool uses_typeless_image_reads{}; | ||
| 156 | bool uses_typeless_image_writes{}; | ||
| 157 | bool uses_image_buffers{}; | ||
| 158 | bool uses_shared_increment{}; | ||
| 159 | bool uses_shared_decrement{}; | ||
| 160 | bool uses_global_increment{}; | ||
| 161 | bool uses_global_decrement{}; | ||
| 162 | bool uses_atomic_f32_add{}; | ||
| 163 | bool uses_atomic_f16x2_add{}; | ||
| 164 | bool uses_atomic_f16x2_min{}; | ||
| 165 | bool uses_atomic_f16x2_max{}; | ||
| 166 | bool uses_atomic_f32x2_add{}; | ||
| 167 | bool uses_atomic_f32x2_min{}; | ||
| 168 | bool uses_atomic_f32x2_max{}; | ||
| 169 | bool uses_atomic_s32_min{}; | ||
| 170 | bool uses_atomic_s32_max{}; | ||
| 171 | bool uses_int64_bit_atomics{}; | ||
| 172 | bool uses_global_memory{}; | ||
| 173 | bool uses_atomic_image_u32{}; | ||
| 174 | bool uses_shadow_lod{}; | ||
| 175 | |||
| 176 | IR::Type used_constant_buffer_types{}; | ||
| 177 | IR::Type used_storage_buffer_types{}; | ||
| 178 | |||
| 179 | u32 constant_buffer_mask{}; | ||
| 180 | std::array<u32, MAX_CBUFS> constant_buffer_used_sizes{}; | ||
| 181 | u32 nvn_buffer_base{}; | ||
| 182 | std::bitset<16> nvn_buffer_used{}; | ||
| 183 | |||
| 184 | boost::container::static_vector<ConstantBufferDescriptor, MAX_CBUFS> | ||
| 185 | constant_buffer_descriptors; | ||
| 186 | boost::container::static_vector<StorageBufferDescriptor, MAX_SSBOS> storage_buffers_descriptors; | ||
| 187 | TextureBufferDescriptors texture_buffer_descriptors; | ||
| 188 | ImageBufferDescriptors image_buffer_descriptors; | ||
| 189 | TextureDescriptors texture_descriptors; | ||
| 190 | ImageDescriptors image_descriptors; | ||
| 191 | }; | ||
| 192 | |||
| 193 | } // namespace Shader | ||