diff options
author | Pierre-Eric Pelloux-Prayer <[email protected]> | 2019-04-29 13:53:29 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-07-30 22:04:26 -0400 |
commit | 7534c536ca0f4b2b123200f421460094034f37a3 (patch) | |
tree | de7fa784e8deafc2c0e055f6ea3e4b8c91a62714 /src/mesa/main/fbobject.c | |
parent | e26c6764f240d748a82c353f7c9a8b30f8a27cd6 (diff) |
mesa: add EXT_dsa (Named)Framebuffer functions
These functions dont support display list as specified:
Should the selector-free versions of various OpenGL 3.0 and
EXT_framebuffer_object framebuffer object commands not be allowed
in display lists [...]?
RESOLVED: Yes
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r-- | src/mesa/main/fbobject.c | 211 |
1 files changed, 200 insertions, 11 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index d95f2444f00..088b45aa732 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -155,6 +155,41 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) fb = (struct gl_framebuffer *) _mesa_HashLookup(ctx->Shared->FrameBuffers, id); + + return fb; +} + + +struct gl_framebuffer * +_mesa_lookup_framebuffer_dsa(struct gl_context *ctx, GLuint id, + const char* func) +{ + struct gl_framebuffer *fb; + + if (id == 0) + return NULL; + + fb = _mesa_lookup_framebuffer(ctx, id); + + /* Name exists but buffer is not initialized */ + if (fb == &DummyFramebuffer) { + fb = ctx->Driver.NewFramebuffer(ctx, id); + _mesa_HashLockMutex(ctx->Shared->FrameBuffers); + _mesa_HashInsert(ctx->Shared->FrameBuffers, id, fb); + _mesa_HashUnlockMutex(ctx->Shared->BufferObjects); + } + /* Name doesn't exist */ + else if (!fb) { + _mesa_HashLockMutex(ctx->Shared->FrameBuffers); + fb = ctx->Driver.NewFramebuffer(ctx, id); + if (!fb) { + _mesa_HashUnlockMutex(ctx->Shared->FrameBuffers); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); + return NULL; + } + _mesa_HashInsertLocked(ctx->Shared->BufferObjects, id, fb); + _mesa_HashUnlockMutex(ctx->Shared->BufferObjects); + } return fb; } @@ -3152,6 +3187,37 @@ _mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target) } +GLenum GLAPIENTRY +_mesa_CheckNamedFramebufferStatusEXT(GLuint framebuffer, GLenum target) +{ + struct gl_framebuffer *fb; + GET_CURRENT_CONTEXT(ctx); + + switch (target) { + case GL_DRAW_FRAMEBUFFER: + case GL_FRAMEBUFFER: + case GL_READ_FRAMEBUFFER: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glCheckNamedFramebufferStatusEXT(invalid target %s)", + _mesa_enum_to_string(target)); + return 0; + } + + if (framebuffer == 0) { + return _mesa_CheckNamedFramebufferStatus(0, target); + } + + fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer, + "glCheckNamedFramebufferStatusEXT"); + if (!fb) + return 0; + + return _mesa_check_framebuffer_status(ctx, fb); +} + + /** * Replicate the src attachment point. Used by framebuffer_texture() when * the same texture is attached at GL_DEPTH_ATTACHMENT and @@ -3606,17 +3672,21 @@ framebuffer_texture_with_dims_no_error(GLenum target, GLenum attachment, static void -framebuffer_texture_with_dims(int dims, GLenum target, +framebuffer_texture_with_dims(int dims, GLenum target, GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples, - GLint layer, const char *caller) + GLint layer, const char *caller, bool dsa) { GET_CURRENT_CONTEXT(ctx); struct gl_framebuffer *fb; struct gl_texture_object *texObj; /* Get the framebuffer object */ - fb = get_framebuffer_target(ctx, target); + if (dsa) { + fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer, caller); + } else { + fb = get_framebuffer_target(ctx, target); + } if (!fb) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller, _mesa_enum_to_string(target)); @@ -3662,8 +3732,8 @@ void GLAPIENTRY _mesa_FramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - framebuffer_texture_with_dims(1, target, attachment, textarget, texture, - level, 0, 0, "glFramebufferTexture1D"); + framebuffer_texture_with_dims(1, target, 0, attachment, textarget, texture, + level, 0, 0, "glFramebufferTexture1D", false); } @@ -3681,8 +3751,8 @@ void GLAPIENTRY _mesa_FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - framebuffer_texture_with_dims(2, target, attachment, textarget, texture, - level, 0, 0, "glFramebufferTexture2D"); + framebuffer_texture_with_dims(2, target, 0, attachment, textarget, texture, + level, 0, 0, "glFramebufferTexture2D", false); } @@ -3691,8 +3761,10 @@ _mesa_FramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) { - framebuffer_texture_with_dims(2, target, attachment, textarget, texture, - level, samples, 0, "glFramebufferTexture2DMultisampleEXT"); + framebuffer_texture_with_dims(2, target, 0, attachment, textarget, texture, + level, samples, 0, + "glFramebufferTexture2DMultisampleEXT", + false); } @@ -3711,8 +3783,8 @@ _mesa_FramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer) { - framebuffer_texture_with_dims(3, target, attachment, textarget, texture, - level, 0, layer, "glFramebufferTexture3D"); + framebuffer_texture_with_dims(3, target, 0, attachment, textarget, texture, + level, 0, layer, "glFramebufferTexture3D", false); } @@ -3879,6 +3951,37 @@ _mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment, } +void GLAPIENTRY +_mesa_NamedFramebufferTexture1DEXT(GLuint framebuffer, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + framebuffer_texture_with_dims(1, GL_FRAMEBUFFER, framebuffer, attachment, + textarget, texture, level, 0, 0, + "glNamedFramebufferTexture1DEXT", true); +} + + +void GLAPIENTRY +_mesa_NamedFramebufferTexture2DEXT(GLuint framebuffer, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + framebuffer_texture_with_dims(2, GL_FRAMEBUFFER, framebuffer, attachment, + textarget, texture, level, 0, 0, + "glNamedFramebufferTexture2DEXT", true); +} + + +void GLAPIENTRY +_mesa_NamedFramebufferTexture3DEXT(GLuint framebuffer, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset) +{ + framebuffer_texture_with_dims(3, GL_FRAMEBUFFER, framebuffer, attachment, + textarget, texture, level, 0, zoffset, + "glNamedFramebufferTexture3DEXT", true); +} + + void _mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, @@ -4060,6 +4163,25 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment, } +void GLAPIENTRY +_mesa_NamedFramebufferRenderbufferEXT(GLuint framebuffer, GLenum attachment, + GLenum renderbuffertarget, + GLuint renderbuffer) +{ + struct gl_framebuffer *fb; + GET_CURRENT_CONTEXT(ctx); + + fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer, + "glNamedFramebufferRenderbufferEXT"); + if (!fb) + return; + + framebuffer_renderbuffer_error(ctx, fb, attachment, renderbuffertarget, + renderbuffer, + "glNamedFramebufferRenderbuffer"); +} + + static void get_framebuffer_attachment_parameter(struct gl_context *ctx, struct gl_framebuffer *buffer, @@ -4462,6 +4584,36 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer, void GLAPIENTRY +_mesa_GetNamedFramebufferAttachmentParameterivEXT(GLuint framebuffer, + GLenum attachment, + GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_framebuffer *buffer; + + if (framebuffer) { + buffer = _mesa_lookup_framebuffer_dsa(ctx, framebuffer, + "glGetNamedFramebufferAttachmentParameterivEXT"); + if (!buffer) + return; + } + else { + /* + * Section 9.2 Binding and Managing Framebuffer Objects of the OpenGL + * 4.5 core spec (30.10.2014, PDF page 314): + * "If framebuffer is zero, then the default draw framebuffer is + * queried." + */ + buffer = ctx->WinSysDrawBuffer; + } + + get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname, + params, + "glGetNamedFramebufferAttachmentParameterivEXT"); +} + + +void GLAPIENTRY _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname, GLint param) { @@ -4492,6 +4644,43 @@ _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname, void GLAPIENTRY +_mesa_GetFramebufferParameterivEXT(GLuint framebuffer, GLenum pname, + GLint *param) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_framebuffer *fb; + + if (framebuffer) + fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer, + "glGetFramebufferParameterivEXT"); + else + fb = ctx->WinSysDrawBuffer; + + if (fb) { + /* The GL_EXT_direct_state_access says: + * + * The pname parameter must be one of framebuffer dependent values + * listed in either table 4.nnn (namely DRAW_BUFFER, READ_BUFFER, + * or DRAW_BUFFER0 through DRAW_BUFFER15). + */ + if (pname == GL_DRAW_BUFFER) { + *param = fb->ColorDrawBuffer[0]; + + } + else if (pname == GL_READ_BUFFER) { + *param = fb->ColorReadBuffer; + } + else if (GL_DRAW_BUFFER0 <= pname && pname <= GL_DRAW_BUFFER15) { + *param = fb->ColorDrawBuffer[pname - GL_DRAW_BUFFER0]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferParameterivEXT(pname)"); + } + } +} + + +void GLAPIENTRY _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname, GLint *param) { |