13 #import <Availability.h>
26 is_loadstore_dirty_ =
true;
27 dirty_state_ctx_ =
nullptr;
28 has_pending_clear_ =
false;
29 colour_attachment_count_ = 0;
30 srgb_enabled_ =
false;
34 mtl_color_attachments_[i].
used =
false;
36 mtl_depth_attachment_.
used =
false;
37 mtl_stencil_attachment_.
used =
false;
40 framebuffer_descriptor_[i] = [[MTLRenderPassDescriptor alloc]
init];
41 descriptor_dirty_[i] =
true;
45 colour_attachment_descriptors_[i] = [[MTLRenderPassColorAttachmentDescriptor alloc]
init];
71 if (framebuffer_descriptor_[config] != nil) {
72 [framebuffer_descriptor_[config] release];
73 framebuffer_descriptor_[config] = nil;
79 if (colour_attachment_descriptors_[i] != nil) {
80 [colour_attachment_descriptors_[i] release];
81 colour_attachment_descriptors_[i] = nil;
88 if (context_ ==
nullptr) {
98 BLI_assert(
false &&
"Trying to use the same frame-buffer in multiple context's.");
103 bool srgb_state_changed = srgb_enabled_ != enabled_srgb;
104 if (context_->
active_fb !=
this || srgb_state_changed) {
105 if (srgb_state_changed) {
108 srgb_enabled_ = enabled_srgb;
125 MTL_LOG_WARNING(
"Attempting to bind FrameBuffer, but no context is active\n");
138 const char *
format =
"Framebuffer %s does not have any attachments.\n";
165 "Framebuffer %s: Color attachment dimensions do not match those of previous "
180 "Framebuffer %s: Color attachment texture does not have usage flag "
181 "'GPU_TEXTURE_USAGE_ATTACHMENT'\n";
195 if (depth_att.
used) {
204 "Framebuffer %n: Depth attachment does not have usage "
205 "'GPU_TEXTURE_USAGE_ATTACHMENT'\n";
219 "Framebuffer %n: Depth attachment dimensions do not match that of previous "
232 if (stencil_att.
used) {
240 "Framebuffer %s: Stencil attachment does not have usage "
241 "'GPU_TEXTURE_USAGE_ATTACHMENT'\n";
256 "Framebuffer %s: Stencil attachment dimensions do not match that of previous "
274 void MTLFrameBuffer::force_clear()
279 if (current_framebuffer) {
291 const float clear_col[4],
303 if (!has_pending_clear_) {
308 bool do_clear =
false;
310 for (
int i = 0; i < colour_attachment_count_; i++) {
326 has_pending_clear_ =
true;
343 if (!has_pending_clear_) {
347 bool do_clear =
false;
356 has_pending_clear_ =
true;
372 const void *clear_value)
378 if (!has_pending_clear_) {
382 bool do_clear =
false;
387 float depth = ((*(
uint32_t *)clear_value) & 0x00FFFFFFu) / (
float)0x00FFFFFFu;
388 int stencil = ((*(
uint32_t *)clear_value) >> 24);
400 float depth = *(
uint32_t *)clear_value / (
float)0xFFFFFFFFu;
409 float col_clear_val[4] = {0.0};
410 switch (data_format) {
412 const float *vals = (
float *)clear_value;
413 col_clear_val[0] = vals[0];
414 col_clear_val[1] = vals[1];
415 col_clear_val[2] = vals[2];
416 col_clear_val[3] = vals[3];
419 const uint *vals = (
uint *)clear_value;
420 col_clear_val[0] = (
float)(vals[0]);
421 col_clear_val[1] = (
float)(vals[1]);
422 col_clear_val[2] = (
float)(vals[2]);
423 col_clear_val[3] = (
float)(vals[3]);
426 const int *vals = (
int *)clear_value;
427 col_clear_val[0] = (
float)(vals[0]);
428 col_clear_val[1] = (
float)(vals[1]);
429 col_clear_val[2] = (
float)(vals[2]);
430 col_clear_val[3] = (
float)(vals[3]);
442 has_pending_clear_ =
true;
474 size_t sample_len =
area[2] *
area[3];
476 int debug_data_size = sample_len * sample_size;
477 tex->read_internal(0,
492 "Attempting to read depth from a framebuffer which does not have a depth "
503 size_t sample_len =
area[2] *
area[3];
505 int debug_data_size = sample_len * sample_size * channel_len;
506 tex->read_internal(0,
523 MTL_LOG_ERROR(
"GPUFramebuffer: Error: Trying to read stencil bit. Unsupported.\n");
559 else if (do_stencil) {
586 is_loadstore_dirty_ =
true;
591 is_loadstore_dirty_ =
true;
596 has_pending_clear_ =
false;
601 has_pending_clear_ =
true;
611 int t_viewport[4], t_scissor[4];
612 update_viewport = update_viewport &&
615 if (update_viewport) {
624 use_multilayered_rendering_ =
false;
631 bool depth_added =
false;
687 first_attachment =
type;
728 first_attachment =
type;
747 if (update_viewport && t_viewport[2] <=
width_ && t_viewport[3] <=
height_) {
766 if (
dirty_state_ ==
false && dirty_state_ctx_ == mtl_ctx) {
774 "Viewport had width and height of (0,0) -- Updating -- DEBUG Safety check\n");
784 dirty_state_ctx_ = mtl_ctx;
788 "Attempting to set FrameBuffer State (VIEWPORT, SCISSOR), But FrameBuffer is not bound to "
789 "current Context.\n");
809 MTL_LOG_WARNING(
"Attachment specified with invalid mip level %u\n", miplevel);
815 colour_attachment_count_ += (!mtl_color_attachments_[slot].
used) ? 1 : 0;
816 mtl_color_attachments_[slot].
used =
true;
817 mtl_color_attachments_[slot].
texture = texture;
818 mtl_color_attachments_[slot].
mip = miplevel;
824 switch (texture->
type_) {
828 mtl_color_attachments_[slot].
slice = 0;
834 MTL_LOG_WARNING(
"TODO: Support layered rendering for 1D array textures, if needed.\n");
837 mtl_color_attachments_[slot].
slice = layer;
842 mtl_color_attachments_[slot].
slice = layer;
845 mtl_color_attachments_[slot].
slice = 0;
847 use_multilayered_rendering_ =
true;
852 mtl_color_attachments_[slot].
slice = 0;
857 use_multilayered_rendering_ =
true;
862 mtl_color_attachments_[slot].
slice = layer;
865 mtl_color_attachments_[slot].
slice = 0;
868 use_multilayered_rendering_ =
true;
874 mtl_color_attachments_[slot].
slice = layer;
877 mtl_color_attachments_[slot].
slice = 0;
880 use_multilayered_rendering_ =
true;
884 mtl_color_attachments_[slot].
slice = 0;
888 MTL_LOG_ERROR(
"MTLFrameBuffer::add_color_attachment Unrecognised texture type %u\n",
894 int width_of_miplayer, height_of_miplayer;
896 width_of_miplayer = texture->
width_get();
905 this->
size_set(width_of_miplayer, height_of_miplayer);
921 "Passing in null texture to MTLFrameBuffer::addColourAttachment (This could be due to not "
922 "all texture types being supported).\n");
933 MTL_LOG_WARNING(
"Attachment specified with invalid mip level %u\n", miplevel);
938 mtl_depth_attachment_.
used =
true;
939 mtl_depth_attachment_.
texture = texture;
940 mtl_depth_attachment_.
mip = miplevel;
946 switch (texture->
type_) {
950 mtl_depth_attachment_.
slice = 0;
956 MTL_LOG_WARNING(
"TODO: Support layered rendering for 1D array textures, if needed\n");
959 mtl_depth_attachment_.
slice = layer;
964 mtl_depth_attachment_.
slice = layer;
967 mtl_depth_attachment_.
slice = 0;
969 use_multilayered_rendering_ =
true;
974 mtl_depth_attachment_.
slice = 0;
979 use_multilayered_rendering_ =
true;
984 mtl_depth_attachment_.
slice = layer;
987 mtl_depth_attachment_.
slice = 0;
990 use_multilayered_rendering_ =
true;
996 mtl_depth_attachment_.
slice = layer;
999 mtl_depth_attachment_.
slice = 0;
1002 use_multilayered_rendering_ =
true;
1006 mtl_depth_attachment_.
slice = 0;
1010 BLI_assert(
false &&
"Unrecognised texture type");
1015 int width_of_miplayer, height_of_miplayer;
1016 if (miplevel <= 0) {
1017 width_of_miplayer = texture->
width_get();
1027 this->
size_set(width_of_miplayer, height_of_miplayer);
1043 "Passing in null texture to MTLFrameBuffer::addDepthAttachment (This could be due to not "
1044 "all texture types being supported).");
1055 MTL_LOG_WARNING(
"Attachment specified with invalid mip level %u\n", miplevel);
1060 mtl_stencil_attachment_.
used =
true;
1061 mtl_stencil_attachment_.
texture = texture;
1062 mtl_stencil_attachment_.
mip = miplevel;
1068 switch (texture->
type_) {
1072 mtl_stencil_attachment_.
slice = 0;
1078 MTL_LOG_WARNING(
"TODO: Support layered rendering for 1D array textures, if needed\n");
1081 mtl_stencil_attachment_.
slice = layer;
1086 mtl_stencil_attachment_.
slice = layer;
1089 mtl_stencil_attachment_.
slice = 0;
1091 use_multilayered_rendering_ =
true;
1096 mtl_stencil_attachment_.
slice = 0;
1101 use_multilayered_rendering_ =
true;
1106 mtl_stencil_attachment_.
slice = layer;
1109 mtl_stencil_attachment_.
slice = 0;
1112 use_multilayered_rendering_ =
true;
1118 mtl_stencil_attachment_.
slice = layer;
1121 mtl_stencil_attachment_.
slice = 0;
1124 use_multilayered_rendering_ =
true;
1128 mtl_stencil_attachment_.
slice = 0;
1132 BLI_assert(
false &&
"Unrecognised texture type");
1137 int width_of_miplayer, height_of_miplayer;
1138 if (miplevel <= 0) {
1139 width_of_miplayer = texture->
width_get();
1149 this->
size_set(width_of_miplayer, height_of_miplayer);
1165 "Passing in null texture to MTLFrameBuffer::addStencilAttachment (This could be due to "
1166 "not all texture types being supported).");
1177 colour_attachment_count_ -= (mtl_color_attachments_[slot].
used) ? 1 : 0;
1178 mtl_color_attachments_[slot].
used =
false;
1191 mtl_depth_attachment_.
used =
false;
1192 mtl_depth_attachment_.
texture =
nullptr;
1203 mtl_stencil_attachment_.
used =
false;
1204 mtl_stencil_attachment_.
texture =
nullptr;
1220 colour_attachment_count_ = 0;
1273 changed = changed || (memcmp(mtl_color_attachments_[slot].clear_value.
color,
1275 sizeof(
float) * 4) != 0);
1277 memcpy(mtl_color_attachments_[slot].clear_value.
color, clear_color,
sizeof(
float) * 4);
1320 mtl_color_attachments_[slot].
load_action = load_action;
1321 mtl_color_attachments_[slot].
store_action = store_action;
1323 bool changed = (mtl_color_attachments_[slot].
load_action != prev_load_action ||
1324 mtl_color_attachments_[slot].
store_action != prev_store_action);
1340 bool changed = (mtl_depth_attachment_.
load_action != prev_load_action ||
1341 mtl_depth_attachment_.
store_action != prev_store_action);
1354 mtl_stencil_attachment_.
load_action = load_action;
1357 bool changed = (mtl_stencil_attachment_.
load_action != prev_load_action ||
1358 mtl_stencil_attachment_.
store_action != prev_store_action);
1368 for (
int slot = 0; slot < colour_attachment_count_; slot++) {
1387 return mtl_color_attachments_[slot].
used;
1397 if (mtl_color_attachments_[attachment].used &&
1398 mtl_color_attachments_[attachment].texture == texture) {
1408 return mtl_depth_attachment_.
used;
1414 return mtl_stencil_attachment_.
used;
1423 if (mtl_color_attachments_[attachment].used &&
1424 (mtl_color_attachments_[attachment].texture == texture)) {
1434 return colour_attachment_count_;
1441 return mtl_color_attachments_[slot];
1444 null_attachment.
used =
false;
1445 return null_attachment;
1451 return mtl_depth_attachment_;
1457 return mtl_stencil_attachment_;
1473 int used_attachments = 0;
1475 if (mtl_color_attachments_[attachment].used) {
1479 used_attachments += (mtl_depth_attachment_.
used) ? 1 : 0;
1480 used_attachments += (mtl_stencil_attachment_.
used) ? 1 : 0;
1481 return (used_attachments > 0);
1499 if (load_contents) {
1512 for (
int config = 0; config < 3; config++) {
1513 descriptor_dirty_[config] =
true;
1516 else if (is_loadstore_dirty_) {
1518 descriptor_dirty_[MTL_FB_CONFIG_CLEAR] =
true;
1519 descriptor_dirty_[MTL_FB_CONFIG_CUSTOM] =
true;
1531 uint descriptor_config = (load_contents) ? MTL_FB_CONFIG_LOAD :
1533 MTL_FB_CONFIG_CUSTOM);
1534 if (descriptor_dirty_[descriptor_config] || framebuffer_descriptor_[descriptor_config] == nil) {
1537 if (framebuffer_descriptor_[descriptor_config] == nil) {
1538 framebuffer_descriptor_[descriptor_config] = [[MTLRenderPassDescriptor alloc]
init];
1541 #if defined(MAC_OS_X_VERSION_11_0) && __MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_11_0
1542 if (@available(macOS 11.00, *)) {
1544 bool is_tile_based_gpu = [metal_ctx->
device hasUnifiedMemory];
1545 if (is_tile_based_gpu) {
1547 bool use_small_tiles = (framebuffer_bpp > 64);
1549 if (use_small_tiles) {
1550 framebuffer_descriptor_[descriptor_config].tileWidth = 16;
1551 framebuffer_descriptor_[descriptor_config].tileHeight = 16;
1558 if (use_multilayered_rendering_) {
1565 if (mtl_color_attachments_[attachment_ind].used) {
1576 if (mtl_depth_attachment_.
used) {
1585 if (mtl_stencil_attachment_.
used) {
1596 framebuffer_descriptor_[descriptor_config].renderTargetArrayLength =
len;
1599 framebuffer_descriptor_[descriptor_config].renderTargetArrayLength = 0;
1603 int colour_attachments = 0;
1606 if (mtl_color_attachments_[attachment_ind].used) {
1609 MTLRenderPassColorAttachmentDescriptor *attachment =
1610 colour_attachment_descriptors_[attachment_ind];
1613 id<MTLTexture> texture =
1614 mtl_color_attachments_[attachment_ind].
texture->get_metal_handle_base();
1615 if (texture == nil) {
1616 MTL_LOG_ERROR(
"Attempting to assign invalid texture as attachment\n");
1621 id<MTLTexture> source_color_texture = texture;
1623 source_color_texture = [texture newTextureViewWithPixelFormat:MTLPixelFormatRGBA8Unorm];
1629 if (descriptor_config == MTL_FB_CONFIG_LOAD) {
1633 else if (descriptor_config == MTL_FB_CONFIG_CUSTOM &&
1638 attachment.texture = source_color_texture;
1640 attachment.clearColor =
1642 MTLClearColorMake(mtl_color_attachments_[attachment_ind].clear_value.
color[0],
1646 MTLClearColorMake(0.0, 0.0, 0.0, 0.0);
1648 mtl_color_attachments_[attachment_ind].store_action);
1649 attachment.level = mtl_color_attachments_[attachment_ind].
mip;
1650 attachment.slice = mtl_color_attachments_[attachment_ind].
slice;
1651 attachment.depthPlane = mtl_color_attachments_[attachment_ind].
depth_plane;
1652 colour_attachments++;
1655 [framebuffer_descriptor_[descriptor_config].colorAttachments setObject:attachment
1656 atIndexedSubscript:attachment_ind];
1660 [framebuffer_descriptor_[descriptor_config].colorAttachments setObject:nil
1661 atIndexedSubscript:attachment_ind];
1664 BLI_assert(colour_attachments == colour_attachment_count_);
1667 if (mtl_depth_attachment_.
used) {
1668 framebuffer_descriptor_[descriptor_config].depthAttachment.texture =
1669 (id<MTLTexture>)mtl_depth_attachment_.
texture->get_metal_handle_base();
1674 if (descriptor_config == MTL_FB_CONFIG_LOAD) {
1682 framebuffer_descriptor_[descriptor_config].depthAttachment.loadAction =
1684 framebuffer_descriptor_[descriptor_config].depthAttachment.clearDepth =
1686 framebuffer_descriptor_[descriptor_config].depthAttachment.storeAction =
1688 framebuffer_descriptor_[descriptor_config].depthAttachment.level = mtl_depth_attachment_.
mip;
1689 framebuffer_descriptor_[descriptor_config].depthAttachment.slice =
1690 mtl_depth_attachment_.
slice;
1691 framebuffer_descriptor_[descriptor_config].depthAttachment.depthPlane =
1695 framebuffer_descriptor_[descriptor_config].depthAttachment.texture = nil;
1699 if (mtl_stencil_attachment_.
used) {
1700 framebuffer_descriptor_[descriptor_config].stencilAttachment.texture =
1701 (id<MTLTexture>)mtl_stencil_attachment_.
texture->get_metal_handle_base();
1706 if (descriptor_config == MTL_FB_CONFIG_LOAD) {
1714 framebuffer_descriptor_[descriptor_config].stencilAttachment.loadAction =
1716 framebuffer_descriptor_[descriptor_config].stencilAttachment.clearStencil =
1718 framebuffer_descriptor_[descriptor_config].stencilAttachment.storeAction =
1720 framebuffer_descriptor_[descriptor_config].stencilAttachment.level =
1721 mtl_stencil_attachment_.
mip;
1722 framebuffer_descriptor_[descriptor_config].stencilAttachment.slice =
1723 mtl_stencil_attachment_.
slice;
1724 framebuffer_descriptor_[descriptor_config].stencilAttachment.depthPlane =
1728 framebuffer_descriptor_[descriptor_config].stencilAttachment.texture = nil;
1730 descriptor_dirty_[descriptor_config] =
false;
1733 is_loadstore_dirty_ =
false;
1734 return framebuffer_descriptor_[descriptor_config];
1756 if (!(
this && metal_fb_write)) {
1766 if (!(do_color || do_depth || do_stencil)) {
1768 " MTLFrameBuffer: requested blit but no color, depth or stencil flag was set\n");
1772 id<MTLBlitCommandEncoder> blit_encoder = nil;
1781 assert(src_attachment.
slice == 0 &&
1782 "currently only supporting slice 0 for graphics framebuffer blit");
1791 dst_attachment.
slice,
1804 if (src_attachment.
used && dst_attachment.
used) {
1807 src_attachment.
texture->blit(blit_encoder,
1811 src_attachment.
slice,
1817 dst_attachment.
slice,
1828 if ((do_depth || do_stencil) && blit_encoder == nil) {
1836 if (src_attachment.
used && dst_attachment.
used) {
1839 src_attachment.
texture->blit(blit_encoder,
1843 src_attachment.
slice,
1849 dst_attachment.
slice,
1865 if (src_attachment.
used && dst_attachment.
used) {
1868 src_attachment.
texture->blit(blit_encoder,
1872 src_attachment.
slice,
1878 dst_attachment.
slice,
typedef float(TangentPoint)[2]
#define BLI_assert_msg(a, msg)
MINLINE int max_ii(int a, int b)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define UNUSED_VARS_NDEBUG(...)
GPUContext * GPU_context_active_get(void)
void GPU_framebuffer_restore(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void GPU_shader_set_framebuffer_srgb_target(int use_srgb_to_linear)
@ GPU_TEXTURE_USAGE_ATTACHMENT
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
void size_set(int width, int height)
uint get_bits_per_pixel()
void viewport_set(const int viewport[4])
void scissor_set(const int scissor[4])
char name_[DEBUG_NAME_LEN]
void scissor_get(int r_scissor[4]) const
void viewport_get(int r_viewport[4]) const
GPUAttachment attachments_[GPU_FB_MAX_ATTACHMENT]
MTLFrameBuffer * get_active_framebuffer()
bool end_active_command_encoder()
bool is_inside_render_pass()
id< MTLBlitCommandEncoder > ensure_begin_blit_encoder()
MTLFrameBuffer * get_current_framebuffer()
void set_scissor_enabled(bool scissor_enabled)
void framebuffer_bind(MTLFrameBuffer *framebuffer)
id< MTLRenderCommandEncoder > ensure_begin_render_pass()
void set_viewport(int origin_x, int origin_y, int width, int height)
void set_scissor(int scissor_x, int scissor_y, int scissor_width, int scissor_height)
MTLCommandBufferManager main_command_buffer
bool remove_stencil_attachment()
bool set_depth_loadstore_op(eGPULoadOp load_action, eGPUStoreOp store_action)
MTLAttachment get_color_attachment(uint slot)
bool remove_color_attachment(uint slot)
void blit(uint read_slot, uint src_x_offset, uint src_y_offset, MTLFrameBuffer *metal_fb_write, uint write_slot, uint dst_x_offset, uint dst_y_offset, uint width, uint height, eGPUFrameBufferBits blit_buffers)
void read(eGPUFrameBufferBits planes, eGPUDataFormat format, const int area[4], int channel_len, int slot, void *r_data) override
void remove_all_attachments()
int get_color_attachment_slot_from_texture(gpu::MTLTexture *texture)
void blit_to(eGPUFrameBufferBits planes, int src_slot, FrameBuffer *dst, int dst_slot, int dst_offset_x, int dst_offset_y) override
bool remove_depth_attachment()
bool check(char err_out[256]) override
bool add_color_attachment(gpu::MTLTexture *texture, uint slot, int miplevel, int layer)
bool set_color_attachment_clear_color(uint slot, const float clear_color[4])
MTLFrameBuffer(MTLContext *ctx, const char *name)
bool set_depth_attachment_clear_value(float depth_clear)
void update_attachments(bool update_viewport)
void ensure_render_target_size()
MTLAttachment get_stencil_attachment()
MTLRenderPassDescriptor * bake_render_pass_descriptor(bool load_contents)
bool has_color_attachment_with_texture(gpu::MTLTexture *texture)
MTLAttachment get_depth_attachment()
void clear_multi(const float(*clear_cols)[4]) override
bool set_stencil_loadstore_op(eGPULoadOp load_action, eGPUStoreOp store_action)
bool set_color_loadstore_op(uint slot, eGPULoadOp load_action, eGPUStoreOp store_action)
uint get_attachment_limit()
bool add_depth_attachment(gpu::MTLTexture *texture, int miplevel, int layer)
void attachment_set_loadstore_op(GPUAttachmentType type, eGPULoadOp load_action, eGPUStoreOp store_action) override
bool validate_render_pass()
bool set_stencil_attachment_clear_value(uint stencil_clear)
bool add_stencil_attachment(gpu::MTLTexture *texture, int miplevel, int layer)
bool has_stencil_attachment()
bool has_attachment_at_slot(uint slot)
void clear_attachment(GPUAttachmentType type, eGPUDataFormat data_format, const void *clear_value) override
void mark_loadstore_dirty()
void clear(eGPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, uint clear_stencil) override
void bind(bool enabled_srgb) override
uint get_attachment_count()
bool has_depth_attachment()
eGPUTextureFormat format_get() const
@ GPU_FB_DEPTH_STENCIL_ATTACHMENT
@ GPU_FB_COLOR_ATTACHMENT5
@ GPU_FB_COLOR_ATTACHMENT2
@ GPU_FB_COLOR_ATTACHMENT3
@ GPU_FB_COLOR_ATTACHMENT4
@ GPU_FB_COLOR_ATTACHMENT1
@ GPU_FB_COLOR_ATTACHMENT0
@ GPU_FB_DEPTH_ATTACHMENT
#define GPU_FB_MAX_COLOR_ATTACHMENT
#define MTL_LOG_WARNING(info,...)
#define MTL_LOG_ERROR(info,...)
#define MTL_FB_CONFIG_MAX
static void area(int d1, int d2, int e1, int e2, float weights[2])
MTLLoadAction mtl_load_action_from_gpu(eGPULoadOp action)
static Context * unwrap(GPUContext *ctx)
static const int MTL_MAX_MIPMAP_COUNT
static size_t to_bytesize(GPUIndexBufType type)
MTLStoreAction mtl_store_action_from_gpu(eGPUStoreOp action)
gpu::MTLTexture * texture
uint render_target_array_length
union blender::gpu::MTLAttachment::@685 clear_value