45 vertex_alloc_length++;
53 return reinterpret_cast<uchar *
>(current_allocation_.
data);
68 if (active_mtl_shader ==
nullptr || !active_mtl_shader->
is_valid() ||
74 "MTLImmediate::end -- cannot perform draw as active shader is NULL or invalid (likely "
75 "unimplemented) (shader %p '%s')",
93 [rec pushDebugGroup:[NSString
94 stringWithFormat:
@"immEnd(verts: %d, shader: %s)",
97 [rec insertDebugSignpost:[NSString stringWithFormat:
@"immEnd(verts: %d, shader: %s)",
121 for (
int i = 0; i <
interface->get_total_attributes(); i++) {
139 attr = check_attribute;
146 "Could not find expected attribute in immediate mode vertex format.");
147 if (attr ==
nullptr) {
149 "MTLImmediate::end Could not find matching attribute '%s' from Shader Interface in "
150 "Vertex Format! - TODO: Bind Dummy attribute",
157 MTLVertexFormat convertedFormat;
159 mtl_shader_attribute.
format,
165 if (can_use_implicit_conversion) {
179 BLI_assert(convertedFormat != MTLVertexFormatInvalid);
212 uchar *buffer_data =
reinterpret_cast<uchar *
>(current_allocation_.
data);
239 bool rendered =
false;
249 uint32_t fan_index_count = num_triangles * 3;
261 for (
int i = 0; i < num_triangles; i++) {
262 index_buffer[a++] = 0;
263 index_buffer[a++] = i + 1;
264 index_buffer[a++] = i + 2;
269 id<MTLBuffer> index_buffer_mtl = nil;
286 [rec drawIndexedPrimitives:MTLPrimitiveTypeTriangle
287 indexCount:fan_index_count
288 indexType:MTLIndexTypeUInt32
289 indexBuffer:index_buffer_mtl
290 indexBufferOffset:index_buffer_offset];
304 MTLPrimitiveType primitive_type = metal_primitive_type_;
319 [rec drawPrimitives:primitive_type vertexStart:0 vertexCount:vertex_count];
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
MINLINE int max_ii(int a, int b)
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
StateManager * state_manager
void register_draw_counters(int vertex_submission)
MTLRenderPassState & get_render_pass_state()
bool ensure_render_pipeline_state(MTLPrimitiveType prim_type)
id< MTLRenderCommandEncoder > ensure_begin_render_pass()
static MTLContext * get()
MTLContextGlobalShaderPipelineState pipeline_state
void ensure_depth_stencil_state(MTLPrimitiveType prim_type)
MTLCommandBufferManager main_command_buffer
MTLScratchBufferManager & get_scratchbuffer_manager()
void bind_vertex_buffer(id< MTLBuffer > buffer, uint64_t buffer_offset, uint index)
MTLTemporaryBuffer scratch_buffer_allocate_range_aligned(uint64_t alloc_size, uint alignment)
void bind_as_ssbo(int slot)
const char * get_name() const
MTLShaderInterface * get_interface()
MTLRenderPipelineStateDescriptor & get_pipeline_descriptor()
StringRefNull name_get() const
#define GPU_SSBO_POLYLINE_POS_BUF_SLOT
#define GPU_SSBO_POLYLINE_COL_BUF_SLOT
#define GPU_SSBO_INDEX_BUF_SLOT
#define MTL_LOG_WARNING(info,...)
#define MTL_LOG_ERROR(info,...)
MTLVertexFormat format_resize_comp(MTLVertexFormat mtl_format, uint32_t components)
static Context * unwrap(GPUContext *ctx)
static MTLPrimitiveType gpu_prim_type_to_metal(GPUPrimType prim_type)
static MTLPrimitiveTopologyClass mtl_prim_type_to_topology_class(MTLPrimitiveType prim_type)
bool mtl_convert_vertex_format(MTLVertexFormat shader_attr_format, GPUVertCompType component_type, uint32_t component_len, GPUVertFetchMode fetch_mode, MTLVertexFormat *r_convertedFormat)
static bool mtl_needs_topology_emulation(GPUPrimType prim_type)
unsigned __int64 uint64_t
id< MTLBuffer > metal_buffer
MTLStorageBufferBinding ssbo_bindings[MTL_MAX_BUFFER_BINDINGS]
void reset_vertex_descriptor()
MTLVertexDescriptor vertex_descriptor
GPUVertFetchMode format_conversion_mode
MTLVertexStepFunction step_function
MTLVertexBufferLayoutDescriptorPSO buffer_layouts[GPU_BATCH_VBO_MAX_LEN+GPU_BATCH_INST_VBO_MAX_LEN]
MTLVertexAttributeDescriptorPSO attributes[GPU_VERT_ATTR_MAX_LEN]