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;
137 int32_t push_constant_location = 1024;
140 input->location = push_constant_location++;
159 BLI_assert_msg(0,
"Resource type is not supported for Geometry frequency");
167 input->location = constant_id++;
189 const uint32_t resources_len = input_tot_len;
192 init_descriptor_set_layout_info(info, resources_len, all_resources, push_constants_storage_type);
196 resource_bindings_.fill({});
207 descriptor_set_location_update(
input,
219 shader::ImageType::Float1DArray,
220 shader::ImageType::Float2DArray,
221 shader::ImageType::FloatCubeArray,
222 shader::ImageType::Int1DArray,
223 shader::ImageType::Int2DArray,
224 shader::ImageType::IntCubeArray,
225 shader::ImageType::Uint1DArray,
226 shader::ImageType::Uint2DArray,
227 shader::ImageType::UintCubeArray,
228 shader::ImageType::AtomicUint2DArray,
229 shader::ImageType::AtomicInt2DArray) ?
235 shader::ImageType::Float1DArray,
236 shader::ImageType::Float2DArray,
237 shader::ImageType::FloatCubeArray,
238 shader::ImageType::Int1DArray,
239 shader::ImageType::Int2DArray,
240 shader::ImageType::IntCubeArray,
241 shader::ImageType::Uint1DArray,
242 shader::ImageType::Uint2DArray,
243 shader::ImageType::UintCubeArray,
244 shader::ImageType::Shadow2DArray,
245 shader::ImageType::ShadowCubeArray,
246 shader::ImageType::Depth2DArray,
247 shader::ImageType::DepthCubeArray,
248 shader::ImageType::AtomicUint2DArray,
249 shader::ImageType::AtomicInt2DArray) ?
260 int32_t push_constant_descriptor_set_location = -1;
264 descriptor_set_location_update(push_constant_input,
265 push_constants_fallback_location,
270 push_constants_layout_.init(
271 info, *
this, push_constants_storage_type, push_constant_descriptor_set_location);
277 int32_t index = (shader_input - shader_inputs);
281void VKShaderInterface::descriptor_set_location_update(
285 std::optional<const shader::ShaderCreateInfo::Resource>
resource,
290 "Incorrect parameters, when no resource is given, it must be the uniform buffer "
291 "for storing push constants or input attachment for subpass inputs.");
293 "Incorrect parameter, bind types do not match.");
299 BLI_assert(resource_bindings_[index].binding == -1);
301 VkAccessFlags vk_access_flags = VK_ACCESS_NONE;
305 vk_access_flags |= VK_ACCESS_UNIFORM_READ_BIT;
310 vk_access_flags |= VK_ACCESS_SHADER_READ_BIT;
313 vk_access_flags |= VK_ACCESS_SHADER_WRITE_BIT;
319 vk_access_flags |= VK_ACCESS_SHADER_READ_BIT;
322 vk_access_flags |= VK_ACCESS_SHADER_WRITE_BIT;
327 vk_access_flags |= VK_ACCESS_SHADER_READ_BIT;
332 vk_access_flags |= VK_ACCESS_UNIFORM_READ_BIT;
335 vk_access_flags |= supports_local_read ? VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
336 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT :
337 VK_ACCESS_SHADER_READ_BIT;
340 VKResourceBinding &resource_binding = resource_bindings_[index];
342 resource_binding.
binding = shader_input->binding;
343 resource_binding.
location = location;
344 resource_binding.
arrayed = arrayed;
352 return resource_bindings_[index];
360 return resource_binding_info(shader_input).location;
366 const ShaderInput *shader_input = shader_input_get(bind_type, binding);
367 if (shader_input ==
nullptr) {
377const ShaderInput *VKShaderInterface::shader_input_get(
383const ShaderInput *VKShaderInterface::shader_input_get(
403void VKShaderInterface::init_descriptor_set_layout_info(
406 Span<shader::ShaderCreateInfo::Resource> all_resources,
409 BLI_assert(descriptor_set_layout_info_.bindings.is_empty());
413 descriptor_set_layout_info_.bindings.reserve(resources_len);
415 descriptor_set_layout_info_.vk_shader_stage_flags = VK_SHADER_STAGE_COMPUTE_BIT;
418 descriptor_set_layout_info_.vk_shader_stage_flags = VK_SHADER_STAGE_FRAGMENT_BIT;
421 descriptor_set_layout_info_.vk_shader_stage_flags = VK_SHADER_STAGE_ALL_GRAPHICS;
426 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
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_