mesa: initial ARB_depth_buffer_float support
Using GL_NONE as DataType of Z32_FLOAT_X24S8, not sure what I should put there. The spec says the type is n/a. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -1131,6 +1131,16 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
|
||||
return GL_DEPTH_STENCIL_EXT;
|
||||
else
|
||||
return 0;
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
if (ctx->Extensions.ARB_depth_buffer_float)
|
||||
return GL_DEPTH_COMPONENT;
|
||||
else
|
||||
return 0;
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
if (ctx->Extensions.ARB_depth_buffer_float)
|
||||
return GL_DEPTH_STENCIL;
|
||||
else
|
||||
return 0;
|
||||
case GL_RED:
|
||||
case GL_R8:
|
||||
case GL_R16:
|
||||
@@ -2266,6 +2276,15 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
|
||||
/* special cases */
|
||||
*params = GL_INDEX;
|
||||
}
|
||||
else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) {
|
||||
/* depends on the attachment parameter */
|
||||
if (attachment == GL_STENCIL_ATTACHMENT) {
|
||||
*params = GL_INDEX;
|
||||
}
|
||||
else {
|
||||
*params = GL_FLOAT;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*params = _mesa_get_format_datatype(format);
|
||||
}
|
||||
|
@@ -1091,6 +1091,25 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 4
|
||||
},
|
||||
/* ARB_depth_buffer_float */
|
||||
{
|
||||
MESA_FORMAT_Z32_FLOAT, /* Name */
|
||||
"MESA_FORMAT_Z32_FLOAT", /* StrName */
|
||||
GL_DEPTH_COMPONENT, /* BaseFormat */
|
||||
GL_FLOAT, /* DataType */
|
||||
0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
|
||||
0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
|
||||
1, 1, 4 /* BlockWidth/Height,Bytes */
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_Z32_FLOAT_X24S8, /* Name */
|
||||
"MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */
|
||||
GL_DEPTH_STENCIL, /* BaseFormat */
|
||||
GL_NONE /* XXX */, /* DataType */
|
||||
0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
|
||||
0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */
|
||||
1, 1, 8 /* BlockWidth/Height,Bytes */
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1654,6 +1673,16 @@ _mesa_format_to_type_and_comps(gl_format format,
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_Z32_FLOAT:
|
||||
*datatype = GL_FLOAT;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_Z32_FLOAT_X24S8:
|
||||
*datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||
*comps = 1;
|
||||
return;
|
||||
|
||||
case MESA_FORMAT_DUDV8:
|
||||
*datatype = GL_BYTE;
|
||||
*comps = 2;
|
||||
|
@@ -209,6 +209,9 @@ typedef enum
|
||||
MESA_FORMAT_RGB9_E5_FLOAT,
|
||||
MESA_FORMAT_R11_G11_B10_FLOAT,
|
||||
|
||||
MESA_FORMAT_Z32_FLOAT,
|
||||
MESA_FORMAT_Z32_FLOAT_X24S8,
|
||||
|
||||
MESA_FORMAT_COUNT
|
||||
} gl_format;
|
||||
|
||||
|
@@ -84,6 +84,7 @@ _mesa_type_is_packed(GLenum type)
|
||||
case GL_UNSIGNED_INT_24_8_EXT:
|
||||
case GL_UNSIGNED_INT_5_9_9_9_REV:
|
||||
case GL_UNSIGNED_INT_10F_11F_11F_REV:
|
||||
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -228,6 +229,8 @@ _mesa_sizeof_packed_type( GLenum type )
|
||||
return sizeof(GLuint);
|
||||
case GL_UNSIGNED_INT_10F_11F_11F_REV:
|
||||
return sizeof(GLuint);
|
||||
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
||||
return 8;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -379,6 +382,11 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type )
|
||||
return sizeof(GLuint);
|
||||
else
|
||||
return -1;
|
||||
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
||||
if (format == GL_DEPTH_STENCIL)
|
||||
return 8;
|
||||
else
|
||||
return -1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -531,8 +539,10 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
|
||||
else
|
||||
return GL_FALSE;
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
if (ctx->Extensions.EXT_packed_depth_stencil
|
||||
&& type == GL_UNSIGNED_INT_24_8_EXT)
|
||||
if ((ctx->Extensions.EXT_packed_depth_stencil &&
|
||||
type == GL_UNSIGNED_INT_24_8_EXT) ||
|
||||
(ctx->Extensions.ARB_depth_buffer_float &&
|
||||
type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
|
||||
return GL_TRUE;
|
||||
else
|
||||
return GL_FALSE;
|
||||
@@ -884,6 +894,7 @@ _mesa_is_depth_format(GLenum format)
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
@@ -931,6 +942,7 @@ _mesa_is_depthstencil_format(GLenum format)
|
||||
switch (format) {
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
@@ -956,6 +968,8 @@ _mesa_is_depth_or_stencil_format(GLenum format)
|
||||
case GL_STENCIL_INDEX16_EXT:
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
|
@@ -61,6 +61,14 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
if (ctx->Extensions.ARB_depth_buffer_float
|
||||
&& type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV
|
||||
&& format != GL_DEPTH_STENCIL_EXT) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* basic combinations test */
|
||||
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
@@ -142,8 +150,21 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
|
||||
}
|
||||
break;
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
if (!ctx->Extensions.EXT_packed_depth_stencil ||
|
||||
type != GL_UNSIGNED_INT_24_8_EXT) {
|
||||
/* Check validity of the type first. */
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_INT_24_8_EXT:
|
||||
if (!ctx->Extensions.EXT_packed_depth_stencil) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
|
||||
return GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
||||
if (!ctx->Extensions.ARB_depth_buffer_float) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
|
||||
return GL_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@@ -66,6 +66,9 @@ get_datatype_bytes(struct gl_renderbuffer *rb)
|
||||
int component_size;
|
||||
|
||||
switch (rb->DataType) {
|
||||
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
||||
component_size = 8;
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_UNSIGNED_INT_24_8_EXT:
|
||||
|
@@ -913,6 +913,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
|
||||
fetch_texel_2d_r11_g11_b10f,
|
||||
fetch_texel_3d_r11_g11_b10f,
|
||||
store_texel_r11_g11_b10f
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_Z32_FLOAT,
|
||||
NULL, /* XXX */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
MESA_FORMAT_Z32_FLOAT_X24S8,
|
||||
NULL, /* XXX */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -416,6 +416,19 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->Extensions.ARB_depth_buffer_float) {
|
||||
switch (internalFormat) {
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT]);
|
||||
return MESA_FORMAT_Z32_FLOAT;
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_X24S8]);
|
||||
return MESA_FORMAT_Z32_FLOAT_X24S8;
|
||||
default:
|
||||
; /* fallthrough */
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->Extensions.ATI_envmap_bumpmap) {
|
||||
switch (internalFormat) {
|
||||
case GL_DUDV_ATI:
|
||||
|
@@ -4419,6 +4419,9 @@ texstore_funcs[MESA_FORMAT_COUNT] =
|
||||
|
||||
{ MESA_FORMAT_RGB9_E5_FLOAT, _mesa_texstore_rgb9_e5 },
|
||||
{ MESA_FORMAT_R11_G11_B10_FLOAT, _mesa_texstore_r11_g11_b10f },
|
||||
|
||||
{ MESA_FORMAT_Z32_FLOAT, NULL /* XXX */ },
|
||||
{ MESA_FORMAT_Z32_FLOAT_X24S8, /* XXX */ },
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user