wined3d: Query info for each resource type from ARB_internalformat_query2.
This commit is contained in:
parent
e4e1e7d8d3
commit
9def5ff409
|
@ -1611,28 +1611,55 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
|
||||||
gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
|
gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLenum wined3d_gl_type_to_enum(enum wined3d_gl_resource_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case WINED3D_GL_RES_TYPE_TEX_1D:
|
||||||
|
return GL_TEXTURE_1D;
|
||||||
|
case WINED3D_GL_RES_TYPE_TEX_2D:
|
||||||
|
return GL_TEXTURE_2D;
|
||||||
|
case WINED3D_GL_RES_TYPE_TEX_3D:
|
||||||
|
return GL_TEXTURE_3D;
|
||||||
|
case WINED3D_GL_RES_TYPE_TEX_CUBE:
|
||||||
|
return GL_TEXTURE_CUBE_MAP_ARB;
|
||||||
|
case WINED3D_GL_RES_TYPE_TEX_RECT:
|
||||||
|
return GL_TEXTURE_RECTANGLE_ARB;
|
||||||
|
case WINED3D_GL_RES_TYPE_BUFFER:
|
||||||
|
return GL_TEXTURE_2D; /* TODO: GL_TEXTURE_BUFFER. */
|
||||||
|
case WINED3D_GL_RES_TYPE_COUNT:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ERR("Unexpected GL resource type %u.\n", type);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void query_format_flag(struct wined3d_gl_info *gl_info, struct wined3d_format *format,
|
static void query_format_flag(struct wined3d_gl_info *gl_info, struct wined3d_format *format,
|
||||||
GLint internal, GLenum pname, DWORD flag, const char *string)
|
GLint internal, GLenum pname, DWORD flag, const char *string)
|
||||||
{
|
{
|
||||||
GLint value;
|
GLint value;
|
||||||
|
enum wined3d_gl_resource_type type;
|
||||||
|
|
||||||
gl_info->gl_ops.ext.p_glGetInternalformativ(GL_TEXTURE_2D, internal, pname, 1, &value);
|
for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
|
||||||
|
{
|
||||||
|
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type), internal, pname, 1, &value);
|
||||||
if (value == GL_FULL_SUPPORT)
|
if (value == GL_FULL_SUPPORT)
|
||||||
{
|
{
|
||||||
TRACE("Format %s supports %s.\n", debug_d3dformat(format->id), string);
|
TRACE("Format %s supports %s, resource type %u.\n", debug_d3dformat(format->id), string, type);
|
||||||
format_set_flag(format, flag);
|
format->flags[type] |= flag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACE("Format %s doesn't support %s.\n", debug_d3dformat(format->id), string);
|
TRACE("Format %s doesn't support %s, resource type %u.\n", debug_d3dformat(format->id), string, type);
|
||||||
format_clear_flag(format, flag);
|
format->flags[type] &= ~flag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Context activation is done by the caller. */
|
/* Context activation is done by the caller. */
|
||||||
static void init_format_fbo_compat_info(struct wined3d_gl_info *gl_info)
|
static void init_format_fbo_compat_info(struct wined3d_gl_info *gl_info)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i, type;
|
||||||
GLuint fbo;
|
GLuint fbo;
|
||||||
|
|
||||||
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
|
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
|
||||||
|
@ -1641,71 +1668,103 @@ static void init_format_fbo_compat_info(struct wined3d_gl_info *gl_info)
|
||||||
{
|
{
|
||||||
GLint value;
|
GLint value;
|
||||||
struct wined3d_format *format = &gl_info->formats[i];
|
struct wined3d_format *format = &gl_info->formats[i];
|
||||||
|
BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
|
||||||
|
GLenum rt_internal = format->rtInternal;
|
||||||
|
|
||||||
if (!format->glInternal)
|
if (!format->glInternal)
|
||||||
continue;
|
continue;
|
||||||
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
|
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gl_info->gl_ops.ext.p_glGetInternalformativ(GL_TEXTURE_2D, format->glInternal,
|
for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
|
||||||
GL_FRAMEBUFFER_RENDERABLE, 1, &value);
|
{
|
||||||
|
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
|
||||||
|
format->glInternal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
|
||||||
if (value == GL_FULL_SUPPORT)
|
if (value == GL_FULL_SUPPORT)
|
||||||
{
|
{
|
||||||
TRACE("Format %s is supported as FBO color attachment.\n", debug_d3dformat(format->id));
|
TRACE("Format %s is supported as FBO color attachment, resource type %u.\n",
|
||||||
format_set_flag(format, WINED3DFMT_FLAG_FBO_ATTACHABLE);
|
debug_d3dformat(format->id), type);
|
||||||
|
format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
|
||||||
format->rtInternal = format->glInternal;
|
format->rtInternal = format->glInternal;
|
||||||
|
regular_fmt_used = TRUE;
|
||||||
|
|
||||||
query_format_flag(gl_info, format, format->glInternal, GL_FRAMEBUFFER_BLEND,
|
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
|
||||||
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING, "post-pixelshader blending");
|
format->glInternal, GL_FRAMEBUFFER_BLEND, 1, &value);
|
||||||
|
if (value == GL_FULL_SUPPORT)
|
||||||
|
{
|
||||||
|
TRACE("Format %s supports post-pixelshader blending, resource type %u.\n",
|
||||||
|
debug_d3dformat(format->id), type);
|
||||||
|
format->flags[type] |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!format->rtInternal)
|
TRACE("Format %s doesn't support post-pixelshader blending, resource typed %u.\n",
|
||||||
|
debug_d3dformat(format->id), type);
|
||||||
|
format->flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
|
if (!rt_internal)
|
||||||
|
{
|
||||||
|
if (format->flags[type] & WINED3DFMT_FLAG_RENDERTARGET)
|
||||||
{
|
{
|
||||||
WARN("Format %s with rendertarget flag is not supported as FBO color attachment"
|
WARN("Format %s with rendertarget flag is not supported as FBO color attachment"
|
||||||
" and no fallback specified.\n", debug_d3dformat(format->id));
|
" and no fallback specified, resource type %u.\n",
|
||||||
format_clear_flag(format, WINED3DFMT_FLAG_RENDERTARGET);
|
debug_d3dformat(format->id), type);
|
||||||
|
format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TRACE("Format %s is not supported as FBO color attachment.\n", debug_d3dformat(format->id));
|
TRACE("Format %s is not supported as FBO color attachment,"
|
||||||
|
" resource type %u.\n", debug_d3dformat(format->id), type);
|
||||||
format->rtInternal = format->glInternal;
|
format->rtInternal = format->glInternal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gl_info->gl_ops.ext.p_glGetInternalformativ(GL_TEXTURE_2D, format->rtInternal,
|
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
|
||||||
GL_FRAMEBUFFER_RENDERABLE, 1, &value);
|
rt_internal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
|
||||||
if (value == GL_FULL_SUPPORT)
|
if (value == GL_FULL_SUPPORT)
|
||||||
{
|
{
|
||||||
TRACE("Format %s rtInternal format is supported as FBO color attachment.\n",
|
TRACE("Format %s rtInternal format is supported as FBO color attachment,"
|
||||||
debug_d3dformat(format->id));
|
" resource type %u.\n", debug_d3dformat(format->id), type);
|
||||||
|
fallback_fmt_used = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN("Format %s rtInternal format is not supported as FBO color attachment.\n",
|
WARN("Format %s rtInternal format is not supported as FBO color attachment,"
|
||||||
debug_d3dformat(format->id));
|
" resource type %u.\n", debug_d3dformat(format->id), type);
|
||||||
format_clear_flag(format, WINED3DFMT_FLAG_RENDERTARGET);
|
format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format->glInternal != format->glGammaInternal)
|
if (format->glInternal != format->glGammaInternal)
|
||||||
{
|
{
|
||||||
gl_info->gl_ops.ext.p_glGetInternalformativ(GL_TEXTURE_2D, format->glGammaInternal,
|
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
|
||||||
GL_FRAMEBUFFER_RENDERABLE, 1, &value);
|
format->glGammaInternal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
|
||||||
if (value == GL_FULL_SUPPORT)
|
if (value == GL_FULL_SUPPORT)
|
||||||
{
|
{
|
||||||
TRACE("Format %s's sRGB format is FBO attachable.\n", debug_d3dformat(format->id));
|
TRACE("Format %s's sRGB format is FBO attachable, resource type %u.\n",
|
||||||
format_set_flag(format, WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB);
|
debug_d3dformat(format->id), type);
|
||||||
|
format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN("Format %s's sRGB format is not FBO attachable.\n", debug_d3dformat(format->id));
|
WARN("Format %s's sRGB format is not FBO attachable, resource type %u.\n",
|
||||||
|
debug_d3dformat(format->id), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
|
else if (format->flags[type] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
|
||||||
format_set_flag(format, WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB);
|
format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fallback_fmt_used && regular_fmt_used)
|
||||||
|
{
|
||||||
|
FIXME("Format %s needs different render target formats for different resource types.\n",
|
||||||
|
debug_d3dformat(format->id));
|
||||||
|
format_clear_flag(format, WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FBO_ATTACHABLE
|
||||||
|
| WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue