GPUFramebuffer: Add support to attach individual texture layer.
This commit is contained in:
@@ -198,6 +198,7 @@ void DRW_framebuffer_bind(struct GPUFrameBuffer *fb);
|
||||
void DRW_framebuffer_clear(bool color, bool depth, bool stencil, float clear_col[4], float clear_depth);
|
||||
void DRW_framebuffer_read_data(int x, int y, int w, int h, int channels, int slot, float *data);
|
||||
void DRW_framebuffer_texture_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int mip);
|
||||
void DRW_framebuffer_texture_layer_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int layer, int mip);
|
||||
void DRW_framebuffer_cubeface_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int face, int mip);
|
||||
void DRW_framebuffer_texture_detach(struct GPUTexture *tex);
|
||||
void DRW_framebuffer_blit(struct GPUFrameBuffer *fb_read, struct GPUFrameBuffer *fb_write, bool depth);
|
||||
|
||||
@@ -2089,10 +2089,16 @@ void DRW_framebuffer_texture_attach(struct GPUFrameBuffer *fb, GPUTexture *tex,
|
||||
GPU_framebuffer_texture_attach(fb, tex, slot, mip);
|
||||
}
|
||||
|
||||
void DRW_framebuffer_texture_layer_attach(struct GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int layer, int mip)
|
||||
{
|
||||
GPU_framebuffer_texture_layer_attach(fb, tex, slot, layer, mip);
|
||||
}
|
||||
|
||||
void DRW_framebuffer_cubeface_attach(struct GPUFrameBuffer *fb, GPUTexture *tex, int slot, int face, int mip)
|
||||
{
|
||||
GPU_framebuffer_texture_cubeface_attach(fb, tex, slot, face, mip);
|
||||
}
|
||||
|
||||
void DRW_framebuffer_texture_detach(GPUTexture *tex)
|
||||
{
|
||||
GPU_framebuffer_texture_detach(tex);
|
||||
|
||||
@@ -51,6 +51,8 @@ void GPU_texture_bind_as_framebuffer(struct GPUTexture *tex);
|
||||
|
||||
GPUFrameBuffer *GPU_framebuffer_create(void);
|
||||
bool GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int mip);
|
||||
bool GPU_framebuffer_texture_layer_attach(
|
||||
GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int layer, int mip);
|
||||
bool GPU_framebuffer_texture_cubeface_attach(
|
||||
GPUFrameBuffer *fb, struct GPUTexture *tex, int slot, int face, int mip);
|
||||
void GPU_framebuffer_texture_detach(struct GPUTexture *tex);
|
||||
|
||||
@@ -163,7 +163,7 @@ bool GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GPU_framebuffer_texture_cubeface_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int face, int mip)
|
||||
static bool gpu_framebuffer_texture_layer_attach_ex(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int layer, int mip, bool cubemap)
|
||||
{
|
||||
GLenum attachment;
|
||||
GLenum facetarget;
|
||||
@@ -183,8 +183,6 @@ bool GPU_framebuffer_texture_cubeface_attach(GPUFrameBuffer *fb, GPUTexture *tex
|
||||
}
|
||||
}
|
||||
|
||||
BLI_assert(GPU_texture_target(tex) == GL_TEXTURE_CUBE_MAP);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb->object);
|
||||
GG.currentfb = fb->object;
|
||||
|
||||
@@ -195,9 +193,13 @@ bool GPU_framebuffer_texture_cubeface_attach(GPUFrameBuffer *fb, GPUTexture *tex
|
||||
else
|
||||
attachment = GL_COLOR_ATTACHMENT0 + slot;
|
||||
|
||||
facetarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, facetarget, GPU_texture_opengl_bindcode(tex), mip);
|
||||
if (cubemap) {
|
||||
facetarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, facetarget, GPU_texture_opengl_bindcode(tex), mip);
|
||||
}
|
||||
else {
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, attachment, GPU_texture_opengl_bindcode(tex), mip, layer);
|
||||
}
|
||||
|
||||
if (GPU_texture_depth(tex))
|
||||
fb->depthtex = tex;
|
||||
@@ -209,6 +211,17 @@ bool GPU_framebuffer_texture_cubeface_attach(GPUFrameBuffer *fb, GPUTexture *tex
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GPU_framebuffer_texture_layer_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int layer, int mip)
|
||||
{
|
||||
return gpu_framebuffer_texture_layer_attach_ex(fb, tex, slot, layer, mip, false);
|
||||
}
|
||||
|
||||
bool GPU_framebuffer_texture_cubeface_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int face, int mip)
|
||||
{
|
||||
BLI_assert(GPU_texture_target(tex) == GL_TEXTURE_CUBE_MAP);
|
||||
return gpu_framebuffer_texture_layer_attach_ex(fb, tex, slot, face, mip, true);
|
||||
}
|
||||
|
||||
void GPU_framebuffer_texture_detach(GPUTexture *tex)
|
||||
{
|
||||
GLenum attachment;
|
||||
|
||||
Reference in New Issue
Block a user