34 static char PUSH_CONSTANTS_FALLBACK_NAME[] =
"push_constants_fallback";
35 static size_t PUSH_CONSTANTS_FALLBACK_NAME_LEN = strlen(PUSH_CONSTANTS_FALLBACK_NAME);
36 static char SUBPASS_FALLBACK_NAME[] =
"gpu_subpass_img_0";
37 static size_t SUBPASS_FALLBACK_NAME_LEN = strlen(SUBPASS_FALLBACK_NAME);
53 switch (res.bind_type) {
76 names_size += PUSH_CONSTANTS_FALLBACK_NAME_LEN + 1;
85 uint32_t name_buffer_offset = 0;
91 if (
input->location != -1) {
110 int32_t push_constants_fallback_location = -1;
138 int32_t push_constant_location = 1024;
141 input->location = push_constant_location++;
160 BLI_assert_msg(0,
"Resource type is not supported for Geometry frequency");
168 input->location = constant_id++;
190 const uint32_t resources_len = input_tot_len;
193 init_descriptor_set_layout_info(info, resources_len, all_resources, push_constants_storage_type);
197 resource_bindings_.fill({});
208 descriptor_set_location_update(
input,
220 shader::ImageType::Float1DArray,
221 shader::ImageType::Float2DArray,
222 shader::ImageType::FloatCubeArray,
223 shader::ImageType::Int1DArray,
224 shader::ImageType::Int2DArray,
225 shader::ImageType::IntCubeArray,
226 shader::ImageType::Uint1DArray,
227 shader::ImageType::Uint2DArray,
228 shader::ImageType::UintCubeArray,
229 shader::ImageType::AtomicUint2DArray,
230 shader::ImageType::AtomicInt2DArray) ?
236 shader::ImageType::Float1DArray,
237 shader::ImageType::Float2DArray,
238 shader::ImageType::FloatCubeArray,
239 shader::ImageType::Int1DArray,
240 shader::ImageType::Int2DArray,
241 shader::ImageType::IntCubeArray,
242 shader::ImageType::Uint1DArray,
243 shader::ImageType::Uint2DArray,
244 shader::ImageType::UintCubeArray,
245 shader::ImageType::Shadow2DArray,
246 shader::ImageType::ShadowCubeArray,
247 shader::ImageType::Depth2DArray,
248 shader::ImageType::DepthCubeArray,
249 shader::ImageType::AtomicUint2DArray,
250 shader::ImageType::AtomicInt2DArray) ?
261 int32_t push_constant_descriptor_set_location = -1;
265 descriptor_set_location_update(push_constant_input,
266 push_constants_fallback_location,
271 push_constants_layout_.init(
272 info, *
this, push_constants_storage_type, push_constant_descriptor_set_location);
278 int32_t index = (shader_input - shader_inputs);
282void VKShaderInterface::descriptor_set_location_update(
286 std::optional<const shader::ShaderCreateInfo::Resource>
resource,
291 "Incorrect parameters, when no resource is given, it must be the uniform buffer "
292 "for storing push constants or input attachment for subpass inputs.");
294 "Incorrect parameter, bind types do not match.");
300 BLI_assert(resource_bindings_[index].binding == -1);
302 VkAccessFlags vk_access_flags = VK_ACCESS_NONE;
306 vk_access_flags |= VK_ACCESS_UNIFORM_READ_BIT;
311 vk_access_flags |= VK_ACCESS_SHADER_READ_BIT;
314 vk_access_flags |= VK_ACCESS_SHADER_WRITE_BIT;
320 vk_access_flags |= VK_ACCESS_SHADER_READ_BIT;
323 vk_access_flags |= VK_ACCESS_SHADER_WRITE_BIT;
328 vk_access_flags |= VK_ACCESS_SHADER_READ_BIT;
333 vk_access_flags |= VK_ACCESS_UNIFORM_READ_BIT;
336 vk_access_flags |= supports_local_read ? VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
337 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT :
338 VK_ACCESS_SHADER_READ_BIT;
341 VKResourceBinding &resource_binding = resource_bindings_[index];
343 resource_binding.
binding = shader_input->binding;
344 resource_binding.
location = location;
345 resource_binding.
arrayed = arrayed;
353 return resource_bindings_[index];
361 return resource_binding_info(shader_input).location;
367 const ShaderInput *shader_input = shader_input_get(bind_type, binding);
368 if (shader_input ==
nullptr) {
378const ShaderInput *VKShaderInterface::shader_input_get(
384const ShaderInput *VKShaderInterface::shader_input_get(
404void VKShaderInterface::init_descriptor_set_layout_info(
407 Span<shader::ShaderCreateInfo::Resource> all_resources,
410 BLI_assert(descriptor_set_layout_info_.bindings.is_empty());
414 descriptor_set_layout_info_.bindings.reserve(resources_len);
416 descriptor_set_layout_info_.vk_shader_stage_flags = VK_SHADER_STAGE_COMPUTE_BIT;
419 descriptor_set_layout_info_.vk_shader_stage_flags = VK_SHADER_STAGE_FRAGMENT_BIT;
422 descriptor_set_layout_info_.vk_shader_stage_flags = VK_SHADER_STAGE_ALL_GRAPHICS;
427 descriptor_set_layout_info_.bindings.append_n_times(
429 VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
432 for (
const shader::ShaderCreateInfo::Resource &res : all_resources) {
436 descriptor_set_layout_info_.bindings.append(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
constexpr bool is_empty() const
void extend(Span< T > array)
void copy_input_name(ShaderInput *input, const StringRefNull &name, char *name_buffer, uint32_t &name_buffer_offset) const
void set_image_formats_from_info(const shader::ShaderCreateInfo &info)
const ShaderInput * uniform_get(const StringRefNull name) const
const ShaderInput * texture_get(const int binding) const
const char * input_name_get(const ShaderInput *input) const
static const char * builtin_uniform_block_name(GPUUniformBlockBuiltin u)
const ShaderInput * ubo_get(const StringRefNull name) const
const ShaderInput * ssbo_get(const StringRefNull name) const
int32_t builtin_blocks_[GPU_NUM_UNIFORM_BLOCKS]
int32_t builtins_[GPU_NUM_UNIFORMS]
uint16_t enabled_attr_mask_
uint8_t attr_types_[GPU_VERT_ATTR_MAX_LEN]
static const char * builtin_uniform_name(GPUUniformBuiltin u)
const VKExtensions & extensions_get() const
const VKDescriptorSet::Location descriptor_set_location(const shader::ShaderCreateInfo::Resource &resource) const
void init(const shader::ShaderCreateInfo &info)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
VkDescriptorType to_vk_descriptor_type(const shader::ShaderCreateInfo::Resource &resource)
static constexpr int BIND_SPACE_IMAGE_OFFSET
static int32_t shader_input_index(const ShaderInput *shader_inputs, const ShaderInput *shader_input)
static VKBindType to_bind_type(shader::ShaderCreateInfo::Resource::BindType bind_type)
bool dynamic_rendering_local_read
static StorageType determine_storage_type(const shader::ShaderCreateInfo &info, const VKDevice &device)
VKImageViewArrayed arrayed
VkAccessFlags access_mask
VKDescriptorSet::Location location
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
StringRefNull compute_source_
Vector< SubpassIn > subpass_inputs_
Vector< Resource > geometry_resources_
Vector< VertIn > vertex_inputs_
Vector< Resource > batch_resources_
size_t interface_names_size_
Vector< Resource > pass_resources_
std::string compute_source_generated
Vector< SpecializationConstant > specialization_constants_
Vector< PushConst > push_constants_