Blender V5.3
mtl_shader_generate.hh File Reference
#include "gpu_shader_create_info.hh"
#include "gpu_shader_private.hh"
#include "mtl_capabilities.hh"
#include <sstream>

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::gpu

Macros

#define MTL_MAX_SSBO   16
#define MTL_MAX_UBO   12
#define MTL_SSBO_SLOT_OFFSET   0
#define MTL_UBO_SLOT_OFFSET   MTL_MAX_SSBO
#define MTL_ACCELERATION_STRUCTURE_SLOT   (MTL_UBO_SLOT_OFFSET + MTL_MAX_UBO)
#define MTL_PUSH_CONSTANT_BUFFER_SLOT   (MTL_ACCELERATION_STRUCTURE_SLOT + 1)
#define MTL_SAMPLER_ARGUMENT_BUFFER_SLOT   (MTL_PUSH_CONSTANT_BUFFER_SLOT + 1)
#define MTL_IMAGE_SLOT_OFFSET   0
#define MTL_SAMPLER_SLOT_OFFSET   MTL_MAX_IMAGE_SLOTS
#define MTL_SPECIALIZATION_CONSTANT_OFFSET   30

Functions

uint32_t blender::gpu::available_buffer_slots (const ShaderCreateInfo &info)
std::pair< std::string, std::string > blender::gpu::generate_entry_point (const ShaderCreateInfo &info, const ShaderStage stage, const StringRefNull entry_point_name)
void blender::gpu::patch_create_info_atomic_workaround (std::unique_ptr< PatchedShaderCreateInfo > &patched_info, const shader::ShaderCreateInfo &original_info)

Macro Definition Documentation

◆ MTL_ACCELERATION_STRUCTURE_SLOT

◆ MTL_IMAGE_SLOT_OFFSET

#define MTL_IMAGE_SLOT_OFFSET   0

Whether they are used for arbitrary load/store or sampling, all textures share a binding space per stage (up to 128 slots on our target devices). However, we keep the same combined texture+sampler semantic as GLSL. The sampler binding space is much more limited (16 on target hardware) which limits the maximum texture we can bind for sampling. We lift this limit by using an Argument Buffer to store the samplers. So we reserve the first 16 slots to images and the remaining ones for sampler textures.

+--------------------------—+-----—+---------—+ | Type | Count | Slot Range | +--------------------------—+-----—+---------—+ | Image Textures | 8 | 0..7 | | Sampler Textures | 64 | 8..71 | +--------------------------—+-----—+---------—+

Definition at line 59 of file mtl_shader_generate.hh.

Referenced by blender::gpu::ensure_texture_bindings(), and blender::gpu::generate_resource().

◆ MTL_MAX_SSBO

#define MTL_MAX_SSBO   16

In Metal UBO, SSBO and Push Constants all share the same binding space with a maximum of 31 bindings per stage. To avoid bind location clash, we associate different ranges to different usage. Given that vertex and index buffers are not present in the shader code, we try to pack them in the remaining unused slots. This is done inside the PSO description building (inside the Batch API).

+--------------------------—+-----—+---------—+ | Type | Count | Slot Range | +--------------------------—+-----—+---------—+ | Vertex Buffers | 16 | 0..30 | | Storage Buffers | 16 | 0..15 | | Uniform Buffers | 12 | 16..27 | | Acceleration Structure | 1 | 28..28 | | Push Constant Buffer | 1 | 29..29 | | Sampler Argument Buffer | 1 | 30..30 | +--------------------------—+-----—+---------—+

Definition at line 36 of file mtl_shader_generate.hh.

◆ MTL_MAX_UBO

#define MTL_MAX_UBO   12

Definition at line 37 of file mtl_shader_generate.hh.

◆ MTL_PUSH_CONSTANT_BUFFER_SLOT

◆ MTL_SAMPLER_ARGUMENT_BUFFER_SLOT

◆ MTL_SAMPLER_SLOT_OFFSET

◆ MTL_SPECIALIZATION_CONSTANT_OFFSET

#define MTL_SPECIALIZATION_CONSTANT_OFFSET   30

◆ MTL_SSBO_SLOT_OFFSET

◆ MTL_UBO_SLOT_OFFSET