Commit 6fa62b26 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Move internal format queries to separate function.

parent e7764212
...@@ -2170,68 +2170,12 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx) ...@@ -2170,68 +2170,12 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo); gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
} }
static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info) static void query_internal_format(struct wined3d_adapter *adapter,
struct wined3d_format *format, const struct wined3d_format_texture_info *texture_info,
struct wined3d_gl_info *gl_info, BOOL srgb_write_supported)
{ {
GLint count, multisample_types[MAX_MULTISAMPLE_TYPES]; GLint count, multisample_types[MAX_MULTISAMPLE_TYPES];
struct fragment_caps fragment_caps; unsigned int i, max_log2;
struct shader_caps shader_caps;
BOOL srgb_write;
unsigned int i, j, max_log2;
adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
srgb_write = (fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_SRGB_WRITE)
&& (shader_caps.wined3d_caps & WINED3D_SHADER_CAP_SRGB_WRITE);
for (i = 0; i < sizeof(format_texture_info) / sizeof(*format_texture_info); ++i)
{
int fmt_idx = getFmtIdx(format_texture_info[i].id);
struct wined3d_format *format;
if (fmt_idx == -1)
{
ERR("Format %s (%#x) not found.\n",
debug_d3dformat(format_texture_info[i].id), format_texture_info[i].id);
return FALSE;
}
if (!gl_info->supported[format_texture_info[i].extension]) continue;
format = &gl_info->formats[fmt_idx];
/* ARB_texture_rg defines floating point formats, but only if
* ARB_texture_float is also supported. */
if (!gl_info->supported[ARB_TEXTURE_FLOAT]
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT))
continue;
format->glInternal = format_texture_info[i].gl_internal;
format->glGammaInternal = format_texture_info[i].gl_srgb_internal;
format->rtInternal = format_texture_info[i].gl_rt_internal;
format->glFormat = format_texture_info[i].gl_format;
format->glType = format_texture_info[i].gl_type;
format->color_fixup = COLOR_FIXUP_IDENTITY;
format->height_scale.numerator = 1;
format->height_scale.denominator = 1;
format->flags[WINED3D_GL_RES_TYPE_TEX_1D] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_TEX_2D] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_BUFFER] |= format_texture_info[i].flags;
/* GL_ARB_depth_texture does not support 3D textures. It also says "cube textures are
* problematic", but doesn't explicitly mandate that an error is generated. */
if (gl_info->supported[EXT_TEXTURE3D]
&& !(format_texture_info[i].flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= format_texture_info[i].flags;
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
format->flags[WINED3D_GL_RES_TYPE_TEX_CUBE] |= format_texture_info[i].flags;
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_RB] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_RB] &= ~WINED3DFMT_FLAG_TEXTURE;
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2]) if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
{ {
...@@ -2245,7 +2189,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win ...@@ -2245,7 +2189,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
query_format_flag(gl_info, format, format->glGammaInternal, GL_SRGB_READ, query_format_flag(gl_info, format, format->glGammaInternal, GL_SRGB_READ,
WINED3DFMT_FLAG_SRGB_READ, "sRGB read"); WINED3DFMT_FLAG_SRGB_READ, "sRGB read");
if (srgb_write) if (srgb_write_supported)
query_format_flag(gl_info, format, format->glGammaInternal, GL_SRGB_WRITE, query_format_flag(gl_info, format, format->glGammaInternal, GL_SRGB_WRITE,
WINED3DFMT_FLAG_SRGB_WRITE, "sRGB write"); WINED3DFMT_FLAG_SRGB_WRITE, "sRGB write");
else else
...@@ -2281,11 +2225,11 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win ...@@ -2281,11 +2225,11 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
} }
} }
if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SRGB_WRITE) && !srgb_write) if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SRGB_WRITE) && !srgb_write_supported)
format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE); format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
if (!gl_info->supported[ARB_DEPTH_TEXTURE] if (!gl_info->supported[ARB_DEPTH_TEXTURE]
&& format_texture_info[i].flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) && texture_info->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{ {
format->flags[WINED3D_GL_RES_TYPE_TEX_1D] &= ~WINED3DFMT_FLAG_TEXTURE; format->flags[WINED3D_GL_RES_TYPE_TEX_1D] &= ~WINED3DFMT_FLAG_TEXTURE;
format->flags[WINED3D_GL_RES_TYPE_TEX_2D] &= ~WINED3DFMT_FLAG_TEXTURE; format->flags[WINED3D_GL_RES_TYPE_TEX_2D] &= ~WINED3DFMT_FLAG_TEXTURE;
...@@ -2307,21 +2251,86 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win ...@@ -2307,21 +2251,86 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
GL_EXTCALL(glGetInternalformativ(GL_RENDERBUFFER, format->glInternal, GL_EXTCALL(glGetInternalformativ(GL_RENDERBUFFER, format->glInternal,
GL_SAMPLES, count, multisample_types)); GL_SAMPLES, count, multisample_types));
checkGLcall("glGetInternalformativ(GL_SAMPLES)"); checkGLcall("glGetInternalformativ(GL_SAMPLES)");
for (j = 0; j < count; ++j) for (i = 0; i < count; ++i)
{ {
if (multisample_types[j] > sizeof(format->multisample_types) * 8) if (multisample_types[i] > sizeof(format->multisample_types) * 8)
continue; continue;
format->multisample_types |= 1u << (multisample_types[j] - 1); format->multisample_types |= 1u << (multisample_types[i] - 1);
} }
} }
else else
{ {
max_log2 = wined3d_log2i(min(gl_info->limits.samples, max_log2 = wined3d_log2i(min(gl_info->limits.samples,
sizeof(format->multisample_types) * 8)); sizeof(format->multisample_types) * 8));
for (j = 1; j <= max_log2; ++j) for (i = 1; i <= max_log2; ++i)
format->multisample_types |= 1u << ((1u << j) - 1); format->multisample_types |= 1u << ((1u << i) - 1);
} }
} }
}
static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info)
{
struct fragment_caps fragment_caps;
struct shader_caps shader_caps;
BOOL srgb_write;
unsigned int i;
adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
srgb_write = (fragment_caps.wined3d_caps & WINED3D_FRAGMENT_CAP_SRGB_WRITE)
&& (shader_caps.wined3d_caps & WINED3D_SHADER_CAP_SRGB_WRITE);
for (i = 0; i < sizeof(format_texture_info) / sizeof(*format_texture_info); ++i)
{
int fmt_idx = getFmtIdx(format_texture_info[i].id);
struct wined3d_format *format;
if (fmt_idx == -1)
{
ERR("Format %s (%#x) not found.\n",
debug_d3dformat(format_texture_info[i].id), format_texture_info[i].id);
return FALSE;
}
if (!gl_info->supported[format_texture_info[i].extension]) continue;
format = &gl_info->formats[fmt_idx];
/* ARB_texture_rg defines floating point formats, but only if
* ARB_texture_float is also supported. */
if (!gl_info->supported[ARB_TEXTURE_FLOAT]
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT))
continue;
format->glInternal = format_texture_info[i].gl_internal;
format->glGammaInternal = format_texture_info[i].gl_srgb_internal;
format->rtInternal = format_texture_info[i].gl_rt_internal;
format->glFormat = format_texture_info[i].gl_format;
format->glType = format_texture_info[i].gl_type;
format->color_fixup = COLOR_FIXUP_IDENTITY;
format->height_scale.numerator = 1;
format->height_scale.denominator = 1;
format->flags[WINED3D_GL_RES_TYPE_TEX_1D] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_TEX_2D] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_BUFFER] |= format_texture_info[i].flags;
/* GL_ARB_depth_texture does not support 3D textures. It also says "cube textures are
* problematic", but doesn't explicitly mandate that an error is generated. */
if (gl_info->supported[EXT_TEXTURE3D]
&& !(format_texture_info[i].flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= format_texture_info[i].flags;
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
format->flags[WINED3D_GL_RES_TYPE_TEX_CUBE] |= format_texture_info[i].flags;
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_RB] |= format_texture_info[i].flags;
format->flags[WINED3D_GL_RES_TYPE_RB] &= ~WINED3DFMT_FLAG_TEXTURE;
query_internal_format(adapter, format, &format_texture_info[i], gl_info, srgb_write);
/* Texture conversion stuff */ /* Texture conversion stuff */
format->convert = format_texture_info[i].convert; format->convert = format_texture_info[i].convert;
......
Markdown is supported
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