Commit 7534c536 authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer Committed by Marek Olšák
Browse files

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
parent e26c6764
......@@ -410,5 +410,71 @@
<param name="access" type="GLbitfield" />
</function>
<function name="FramebufferDrawBufferEXT">
<param name="framebuffer" type="GLuint" />
<param name="mode" type="GLenum" />
</function>
<function name="FramebufferDrawBuffersEXT">
<param name="framebuffer" type="GLuint" />
<param name="n" type="GLsizei" />
<param name="bufs" type="const GLenum *" />
</function>
<function name="FramebufferReadBufferEXT">
<param name="framebuffer" type="GLuint" />
<param name="mode" type="GLenum" />
</function>
<function name="GetFramebufferParameterivEXT">
<param name="framebuffer" type="GLuint" />
<param name="pname" type="GLenum" />
<param name="param" type="GLint *" />
</function>
<function name="CheckNamedFramebufferStatusEXT">
<return type="GLenum" />
<param name="framebuffer" type="GLuint" />
<param name="target" type="GLenum" />
</function>
<function name="NamedFramebufferTexture1DEXT">
<param name="framebuffer" type="GLuint" />
<param name="attachment" type="GLenum" />
<param name="textarget" type="GLenum" />
<param name="texture" type="GLuint" />
<param name="level" type="GLint" />
</function>
<function name="NamedFramebufferTexture2DEXT">
<param name="framebuffer" type="GLuint" />
<param name="attachment" type="GLenum" />
<param name="textarget" type="GLenum" />
<param name="texture" type="GLuint" />
<param name="level" type="GLint" />
</function>
<function name="NamedFramebufferTexture3DEXT">
<param name="framebuffer" type="GLuint" />
<param name="attachment" type="GLenum" />
<param name="textarget" type="GLenum" />
<param name="texture" type="GLuint" />
<param name="level" type="GLint" />
<param name="zoffset" type="GLint" />
</function>
<function name="NamedFramebufferRenderbufferEXT">
<param name="framebuffer" type="GLuint" />
<param name="attachment" type="GLenum" />
<param name="renderbuffertarget" type="GLenum" />
<param name="renderbuffer" type="GLuint" />
</function>
<function name="GetNamedFramebufferAttachmentParameterivEXT">
<param name="framebuffer" type="GLuint" />
<param name="attachment" type="GLenum" />
<param name="pname" type="GLenum" />
<param name="params" type="GLint *" />
</function>
</category>
</OpenGLAPI>
......@@ -1504,6 +1504,17 @@ offsets = {
"GetNamedBufferPointervEXT": 1468,
"GetNamedBufferParameterivEXT": 1469,
"FlushMappedNamedBufferRangeEXT": 1470,
"FramebufferDrawBufferEXT": 1471,
"FramebufferDrawBuffersEXT": 1472,
"FramebufferReadBufferEXT": 1473,
"GetFramebufferParameterivEXT": 1474,
"CheckNamedFramebufferStatusEXT": 1475,
"NamedFramebufferTexture1DEXT": 1476,
"NamedFramebufferTexture2DEXT": 1477,
"NamedFramebufferTexture3DEXT": 1478,
"NamedFramebufferRenderbufferEXT": 1479,
"GetNamedFramebufferAttachmentParameterivEXT": 1480,
}
functions = [
......
......@@ -35,6 +35,7 @@
#include "context.h"
#include "enums.h"
#include "fbobject.h"
#include "hash.h"
#include "mtypes.h"
#include "util/bitscan.h"
#include "util/u_math.h"
......@@ -376,6 +377,25 @@ _mesa_NamedFramebufferDrawBuffer_no_error(GLuint framebuffer, GLenum buf)
}
void GLAPIENTRY
_mesa_FramebufferDrawBufferEXT(GLuint framebuffer, GLenum buf)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
if (framebuffer) {
fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer,
"glFramebufferDrawBufferEXT");
if (!fb)
return;
}
else
fb = ctx->WinSysDrawBuffer;
draw_buffer_error(ctx, fb, buf, "glFramebufferDrawBufferEXT");
}
void GLAPIENTRY
_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
{
......@@ -649,6 +669,24 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
draw_buffers_error(ctx, ctx->DrawBuffer, n, buffers, "glDrawBuffers");
}
void GLAPIENTRY
_mesa_FramebufferDrawBuffersEXT(GLuint framebuffer, GLsizei n,
const GLenum *bufs)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
if (framebuffer) {
fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer,
"glFramebufferDrawBuffersEXT");
if (!fb)
return;
}
else
fb = ctx->WinSysDrawBuffer;
draw_buffers_error(ctx, fb, n, bufs, "glFramebufferDrawBuffersEXT");
}
void GLAPIENTRY
_mesa_NamedFramebufferDrawBuffers_no_error(GLuint framebuffer, GLsizei n,
......@@ -959,6 +997,25 @@ _mesa_NamedFramebufferReadBuffer_no_error(GLuint framebuffer, GLenum src)
}
void GLAPIENTRY
_mesa_FramebufferReadBufferEXT(GLuint framebuffer, GLenum buf)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_framebuffer *fb;
if (framebuffer) {
fb = _mesa_lookup_framebuffer_dsa(ctx, framebuffer,
"glFramebufferReadBufferEXT");
if (!fb)
return;
}
else
fb = ctx->WinSysDrawBuffer;
read_buffer_err(ctx, fb, buf, "glFramebufferReadBufferEXT");
}
void GLAPIENTRY
_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
{
......
......@@ -90,5 +90,13 @@ _mesa_NamedFramebufferReadBuffer_no_error(GLuint framebuffer, GLenum src);
extern void GLAPIENTRY
_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src);
extern void GLAPIENTRY
_mesa_FramebufferDrawBufferEXT(GLuint framebuffer, GLenum buf);
extern void GLAPIENTRY
_mesa_FramebufferReadBufferEXT(GLuint framebuffer, GLenum buf);
extern void GLAPIENTRY
_mesa_FramebufferDrawBuffersEXT(GLuint framebuffer, GLsizei n,
const GLenum *bufs);
#endif
......@@ -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,
......@@ -4461,6 +4583,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)
......@@ -4491,6 +4643,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)
......
......@@ -74,6 +74,10 @@ extern struct gl_framebuffer *
_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
const char *func);
struct gl_framebuffer *
_mesa_lookup_framebuffer_dsa(struct gl_context *ctx, GLuint id,
const char* func);
void
_mesa_update_texture_renderbuffer(struct gl_context *ctx,
......@@ -235,6 +239,9 @@ _mesa_CheckFramebufferStatus(GLenum target);
extern GLenum GLAPIENTRY
_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target);
extern GLenum GLAPIENTRY
_mesa_CheckNamedFramebufferStatusEXT(GLuint framebuffer, GLenum target);
extern void GLAPIENTRY
_mesa_FramebufferTexture1D_no_error(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
......@@ -296,6 +303,24 @@ extern void GLAPIENTRY
_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
GLuint texture, GLint level);
extern void GLAPIENTRY
_mesa_NamedFramebufferRenderbufferEXT(GLuint framebuffer, GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer);
extern void GLAPIENTRY
_mesa_NamedFramebufferTexture1DEXT(GLuint framebuffer, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
extern void GLAPIENTRY
_mesa_NamedFramebufferTexture2DEXT(GLuint framebuffer, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
extern void GLAPIENTRY
_mesa_NamedFramebufferTexture3DEXT(GLuint framebuffer, GLenum attachment,
GLenum textarget, GLuint texture,
GLint level, GLint zoffset);
void GLAPIENTRY
_mesa_FramebufferRenderbuffer_no_error(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
......@@ -319,16 +344,26 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
extern void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
GLenum pname, GLint *params);
GLenum pname, GLint *params);
extern void GLAPIENTRY
_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
GLenum attachment,
GLenum pname, GLint *params);
extern void GLAPIENTRY
_mesa_GetNamedFramebufferAttachmentParameterivEXT(GLuint framebuffer,
GLenum attachment,
GLenum pname, GLint *params);
extern void GLAPIENTRY
_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
GLint param);
extern void GLAPIENTRY
_mesa_GetFramebufferParameterivEXT(GLuint framebuffer, GLenum pname,
GLint *param);
extern void GLAPIENTRY
_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
GLint *param);
......
......@@ -1189,18 +1189,18 @@ const struct function common_desktop_functions_possible[] = {
//{ "glNamedRenderbufferStorageEXT", 30, -1 },
//{ "glGetNamedRenderbufferParameterivEXT", 30, -1 },
//{ "glNamedRenderbufferStorageMultisampleEXT", 30, -1 },
//{ "glCheckNamedFramebufferStatusEXT", 30, -1 },
//{ "glNamedFramebufferTexture1DEXT", 30, -1 },
//{ "glNamedFramebufferTexture2DEXT", 30, -1 },
//{ "glNamedFramebufferTexture3DEXT", 30, -1 },
//{ "glNamedFramebufferRenderbufferEXT", 30, -1 },
//{ "glGetNamedFramebufferAttachmentParameterivEXT", 30, -1 },
{ "glCheckNamedFramebufferStatusEXT", 30, -1 },
{ "glNamedFramebufferTexture1DEXT", 30, -1 },
{ "glNamedFramebufferTexture2DEXT", 30, -1 },
{ "glNamedFramebufferTexture3DEXT", 30, -1 },
{ "glNamedFramebufferRenderbufferEXT", 30, -1 },
{ "glGetNamedFramebufferAttachmentParameterivEXT", 30, -1 },
//{ "glGenerateTextureMipmapEXT", 30, -1 },
//{ "glGenerateMultiTexMipmapEXT", 30, -1 },
//{ "glFramebufferDrawBufferEXT", 30, -1 },
//{ "glFramebufferDrawBuffersEXT", 30, -1 },
//{ "glFramebufferReadBufferEXT", 30, -1 },
//{ "glGetFramebufferParameterivEXT", 30, -1 },
{ "glFramebufferDrawBufferEXT", 30, -1 },
{ "glFramebufferDrawBuffersEXT", 30, -1 },
{ "glFramebufferReadBufferEXT", 30, -1 },
{ "glGetFramebufferParameterivEXT", 30, -1 },
//{ "glNamedCopyBufferSubDataEXT", 30, -1 },
//{ "glVertexArrayVertexOffsetEXT", 30, -1 },
//{ "glVertexArrayColorOffsetEXT", 30, -1 },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment