Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_framebuffer.c
| Show First 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | |||||
| /* ---------- Config (Attach & Detach) ----------- */ | /* ---------- Config (Attach & Detach) ----------- */ | ||||
| /** | /** | ||||
| * First GPUAttachment in *config is always the depth/depth_stencil buffer. | * First GPUAttachment in *config is always the depth/depth_stencil buffer. | ||||
| * Following GPUAttachments are color buffers. | * Following GPUAttachments are color buffers. | ||||
| * Setting GPUAttachment.mip to -1 will leave the texture in this slot. | * Setting GPUAttachment.mip to -1 will leave the texture in this slot. | ||||
| * Setting GPUAttachment.tex to NULL will detach the texture in this slot. | * Setting GPUAttachment.tex to NULL will detach the texture in this slot. | ||||
| **/ | */ | ||||
| void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len) | void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len) | ||||
| { | { | ||||
| if (config[0].tex) { | if (config[0].tex) { | ||||
| BLI_assert(GPU_texture_depth(config[0].tex)); | BLI_assert(GPU_texture_depth(config[0].tex)); | ||||
| gpu_framebuffer_texture_attach_ex(fb, config[0].tex, 0, config[0].layer, config[0].mip); | gpu_framebuffer_texture_attach_ex(fb, config[0].tex, 0, config[0].layer, config[0].mip); | ||||
| } | } | ||||
| else if (config[0].mip == -1) { | else if (config[0].mip == -1) { | ||||
| /* Leave texture attached */ | /* Leave texture attached */ | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb) | ||||
| else | else | ||||
| glDrawBuffer(GL_NONE); | glDrawBuffer(GL_NONE); | ||||
| } | } | ||||
| /** | /** | ||||
| * Hack to solve the problem of some bugged AMD GPUs (see `GPU_unused_fb_slot_workaround`). | * Hack to solve the problem of some bugged AMD GPUs (see `GPU_unused_fb_slot_workaround`). | ||||
| * If there is an empty color slot between the color slots, | * If there is an empty color slot between the color slots, | ||||
| * all textures after this slot are apparently skipped/discarded. | * all textures after this slot are apparently skipped/discarded. | ||||
| **/ | */ | ||||
| static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuffer *fb) | static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuffer *fb) | ||||
| { | { | ||||
| GLenum gl_attachments[GPU_FB_MAX_COLOR_ATTACHMENT]; | GLenum gl_attachments[GPU_FB_MAX_COLOR_ATTACHMENT]; | ||||
| int dummy_tex = 0; | int dummy_tex = 0; | ||||
| BLI_assert(GPU_framebuffer_active_get() == fb); | BLI_assert(GPU_framebuffer_active_get() == fb); | ||||
| /* Update attachments */ | /* Update attachments */ | ||||
| ▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | else { | ||||
| glBindFramebuffer(GL_FRAMEBUFFER, 0); | glBindFramebuffer(GL_FRAMEBUFFER, 0); | ||||
| gpu_framebuffer_current_set(NULL); | gpu_framebuffer_current_set(NULL); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Use this if you need to custom downsample your texture and use the previous mip level as input. | * Use this if you need to custom downsample your texture and use the previous mip level as input. | ||||
| * This function only takes care of the correct texture handling. It execute the callback for each texture level. | * This function only takes care of the correct texture handling. It execute the callback for each texture level. | ||||
| **/ | */ | ||||
| void GPU_framebuffer_recursive_downsample( | void GPU_framebuffer_recursive_downsample( | ||||
| GPUFrameBuffer *fb, int max_lvl, | GPUFrameBuffer *fb, int max_lvl, | ||||
| void (*callback)(void *userData, int level), void *userData) | void (*callback)(void *userData, int level), void *userData) | ||||
| { | { | ||||
| /* Framebuffer must be up to date and bound. This simplify this function. */ | /* Framebuffer must be up to date and bound. This simplify this function. */ | ||||
| if (GPU_framebuffer_active_get() != fb || fb->dirty_flag != 0 || fb->object == 0) { | if (GPU_framebuffer_active_get() != fb || fb->dirty_flag != 0 || fb->object == 0) { | ||||
| GPU_framebuffer_bind(fb); | GPU_framebuffer_bind(fb); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 259 Lines • Show Last 20 Lines | |||||