Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/metal/mtl_framebuffer.mm
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | MTLFrameBuffer::~MTLFrameBuffer() | ||||
| } | } | ||||
| } | } | ||||
| void MTLFrameBuffer::bind(bool enabled_srgb) | void MTLFrameBuffer::bind(bool enabled_srgb) | ||||
| { | { | ||||
| /* Verify Context is valid. */ | /* Verify Context is valid. */ | ||||
| if (context_ != static_cast<MTLContext *>(unwrap(GPU_context_active_get()))) { | if (context_ != static_cast<MTLContext *>(unwrap(GPU_context_active_get()))) { | ||||
| BLI_assert(false && "Trying to use the same frame-buffer in multiple context's."); | BLI_assert_msg(false, "Trying to use the same frame-buffer in multiple context's."); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Ensure SRGB state is up-to-date and valid. */ | /* Ensure SRGB state is up-to-date and valid. */ | ||||
| bool srgb_state_changed = srgb_enabled_ != enabled_srgb; | bool srgb_state_changed = srgb_enabled_ != enabled_srgb; | ||||
| if (context_->active_fb != this || srgb_state_changed) { | if (context_->active_fb != this || srgb_state_changed) { | ||||
| if (srgb_state_changed) { | if (srgb_state_changed) { | ||||
| this->mark_dirty(); | this->mark_dirty(); | ||||
| ▲ Show 20 Lines • Show All 874 Lines • ▼ Show 20 Lines | switch (texture->type_) { | ||||
| break; | break; | ||||
| case GPU_TEXTURE_CUBE: | case GPU_TEXTURE_CUBE: | ||||
| BLI_assert(layer < 6); | BLI_assert(layer < 6); | ||||
| mtl_depth_attachment_.slice = layer; | mtl_depth_attachment_.slice = layer; | ||||
| mtl_depth_attachment_.depth_plane = 0; | mtl_depth_attachment_.depth_plane = 0; | ||||
| if (layer == -1) { | if (layer == -1) { | ||||
| mtl_depth_attachment_.slice = 0; | mtl_depth_attachment_.slice = 0; | ||||
| mtl_depth_attachment_.depth_plane = 0; | mtl_depth_attachment_.depth_plane = 0; | ||||
| mtl_depth_attachment_.render_target_array_length = 1; | mtl_depth_attachment_.render_target_array_length = 6; | ||||
| use_multilayered_rendering_ = true; | use_multilayered_rendering_ = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case GPU_TEXTURE_CUBE_ARRAY: | case GPU_TEXTURE_CUBE_ARRAY: | ||||
| /* TODO(Metal): Verify multilayered rendering for Cube arrays. */ | /* TODO(Metal): Verify multilayered rendering for Cube arrays. */ | ||||
| BLI_assert(layer < 6 * texture->d_); | BLI_assert(layer < 6 * texture->d_); | ||||
| mtl_depth_attachment_.slice = layer; | mtl_depth_attachment_.slice = layer; | ||||
| mtl_depth_attachment_.depth_plane = 0; | mtl_depth_attachment_.depth_plane = 0; | ||||
| if (layer == -1) { | if (layer == -1) { | ||||
| mtl_depth_attachment_.slice = 0; | mtl_depth_attachment_.slice = 0; | ||||
| mtl_depth_attachment_.depth_plane = 0; | mtl_depth_attachment_.depth_plane = 0; | ||||
| mtl_depth_attachment_.render_target_array_length = texture->d_; | mtl_depth_attachment_.render_target_array_length = texture->d_; | ||||
| use_multilayered_rendering_ = true; | use_multilayered_rendering_ = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case GPU_TEXTURE_BUFFER: | case GPU_TEXTURE_BUFFER: | ||||
| mtl_depth_attachment_.slice = 0; | mtl_depth_attachment_.slice = 0; | ||||
| mtl_depth_attachment_.depth_plane = 0; | mtl_depth_attachment_.depth_plane = 0; | ||||
| break; | break; | ||||
| default: | default: | ||||
| BLI_assert(false && "Unrecognized texture type"); | BLI_assert_msg(false, "Unrecognized texture type"); | ||||
| break; | break; | ||||
| } | } | ||||
| /* Update Frame-buffer Resolution. */ | /* Update Frame-buffer Resolution. */ | ||||
| int width_of_miplayer, height_of_miplayer; | int width_of_miplayer, height_of_miplayer; | ||||
| if (miplevel <= 0) { | if (miplevel <= 0) { | ||||
| width_of_miplayer = texture->width_get(); | width_of_miplayer = texture->width_get(); | ||||
| height_of_miplayer = texture->height_get(); | height_of_miplayer = texture->height_get(); | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | switch (texture->type_) { | ||||
| break; | break; | ||||
| case GPU_TEXTURE_CUBE: | case GPU_TEXTURE_CUBE: | ||||
| BLI_assert(layer < 6); | BLI_assert(layer < 6); | ||||
| mtl_stencil_attachment_.slice = layer; | mtl_stencil_attachment_.slice = layer; | ||||
| mtl_stencil_attachment_.depth_plane = 0; | mtl_stencil_attachment_.depth_plane = 0; | ||||
| if (layer == -1) { | if (layer == -1) { | ||||
| mtl_stencil_attachment_.slice = 0; | mtl_stencil_attachment_.slice = 0; | ||||
| mtl_stencil_attachment_.depth_plane = 0; | mtl_stencil_attachment_.depth_plane = 0; | ||||
| mtl_stencil_attachment_.render_target_array_length = 1; | mtl_stencil_attachment_.render_target_array_length = 6; | ||||
| use_multilayered_rendering_ = true; | use_multilayered_rendering_ = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case GPU_TEXTURE_CUBE_ARRAY: | case GPU_TEXTURE_CUBE_ARRAY: | ||||
| /* TODO(Metal): Verify multilayered rendering for Cube arrays. */ | /* TODO(Metal): Verify multilayered rendering for Cube arrays. */ | ||||
| BLI_assert(layer < 6 * texture->d_); | BLI_assert(layer < 6 * texture->d_); | ||||
| mtl_stencil_attachment_.slice = layer; | mtl_stencil_attachment_.slice = layer; | ||||
| mtl_stencil_attachment_.depth_plane = 0; | mtl_stencil_attachment_.depth_plane = 0; | ||||
| if (layer == -1) { | if (layer == -1) { | ||||
| mtl_stencil_attachment_.slice = 0; | mtl_stencil_attachment_.slice = 0; | ||||
| mtl_stencil_attachment_.depth_plane = 0; | mtl_stencil_attachment_.depth_plane = 0; | ||||
| mtl_stencil_attachment_.render_target_array_length = texture->d_; | mtl_stencil_attachment_.render_target_array_length = texture->d_; | ||||
| use_multilayered_rendering_ = true; | use_multilayered_rendering_ = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case GPU_TEXTURE_BUFFER: | case GPU_TEXTURE_BUFFER: | ||||
| mtl_stencil_attachment_.slice = 0; | mtl_stencil_attachment_.slice = 0; | ||||
| mtl_stencil_attachment_.depth_plane = 0; | mtl_stencil_attachment_.depth_plane = 0; | ||||
| break; | break; | ||||
| default: | default: | ||||
| BLI_assert(false && "Unrecognized texture type"); | BLI_assert_msg(false, "Unrecognized texture type"); | ||||
| break; | break; | ||||
| } | } | ||||
| /* Update Frame-buffer Resolution. */ | /* Update Frame-buffer Resolution. */ | ||||
| int width_of_miplayer, height_of_miplayer; | int width_of_miplayer, height_of_miplayer; | ||||
| if (miplevel <= 0) { | if (miplevel <= 0) { | ||||
| width_of_miplayer = texture->width_get(); | width_of_miplayer = texture->width_get(); | ||||
| height_of_miplayer = texture->height_get(); | height_of_miplayer = texture->height_get(); | ||||
| ▲ Show 20 Lines • Show All 759 Lines • Show Last 20 Lines | |||||