GPU framebuffer/texture API: Warn when binding a texture that is also
attached to a framebuffer or vice versa. might be more correct to just handle the case and unbind here.
This commit is contained in:
parent
998a867ba3
commit
0f947f2cc5
|
@ -103,6 +103,16 @@ static struct GPUGlobal {
|
|||
GPUTexture *invalid_tex_3D;
|
||||
} GG = {1, 0};
|
||||
|
||||
/* Number of maximum output slots. We support 4 outputs for now (usually we wouldn't need more to preserve fill rate) */
|
||||
#define GPU_FB_MAX_SLOTS 4
|
||||
|
||||
struct GPUFrameBuffer {
|
||||
GLuint object;
|
||||
GPUTexture *colortex[GPU_FB_MAX_SLOTS];
|
||||
GPUTexture *depthtex;
|
||||
};
|
||||
|
||||
|
||||
/* GPU Types */
|
||||
|
||||
int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
|
||||
|
@ -739,7 +749,13 @@ void GPU_texture_bind(GPUTexture *tex, int number)
|
|||
return;
|
||||
}
|
||||
|
||||
if (number == -1)
|
||||
if (tex->fb) {
|
||||
if (tex->fb->object == GG.currentfb) {
|
||||
fprintf(stderr, "Feedback loop warning!: Attempting to bind texture attached to current framebuffer!\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (number < 0)
|
||||
return;
|
||||
|
||||
GPU_print_error("Pre Texture Bind");
|
||||
|
@ -833,15 +849,6 @@ GPUFrameBuffer *GPU_texture_framebuffer(GPUTexture *tex)
|
|||
|
||||
/* GPUFrameBuffer */
|
||||
|
||||
/* Number of maximum output slots. We support 4 outputs for now (usually we wouldn't need more to preserve fill rate) */
|
||||
#define GPU_FB_MAX_SLOTS 4
|
||||
|
||||
struct GPUFrameBuffer {
|
||||
GLuint object;
|
||||
GPUTexture *colortex[GPU_FB_MAX_SLOTS];
|
||||
GPUTexture *depthtex;
|
||||
};
|
||||
|
||||
GPUFrameBuffer *GPU_framebuffer_create(void)
|
||||
{
|
||||
GPUFrameBuffer *fb;
|
||||
|
@ -873,6 +880,10 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (tex->target != -1) {
|
||||
fprintf(stderr, "Feedback loop warning!: Attempting to attach texture to framebuffer while still bound to texture unit for drawing!");
|
||||
}
|
||||
|
||||
if (tex->depth)
|
||||
attachment = GL_DEPTH_ATTACHMENT_EXT;
|
||||
else
|
||||
|
@ -929,7 +940,7 @@ void GPU_framebuffer_texture_detach(GPUTexture *tex)
|
|||
GLenum attachment;
|
||||
GPUFrameBuffer *fb;
|
||||
|
||||
if (!tex->fb || tex->fb_attachment == -1)
|
||||
if (!tex->fb)
|
||||
return;
|
||||
|
||||
fb = tex->fb;
|
||||
|
|
Loading…
Reference in New Issue