On 22 May 2015 at 10:11, Stefan Dösinger stefan@codeweavers.com wrote:
@@ -1145,18 +1151,21 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 /* WINED3DUSAGE_DEPTHSTENCIL needs WINED3DFMT_FLAG_DEPTH or WINED3DFMT_FLAG_STENCIL, not both. */
if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & required_flags) == required_flags
&& (!(desc->usage & WINED3DUSAGE_DEPTHSTENCIL) || (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & ds_flags))
else if ((format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] & required_flags) == required_flags&& check_ds_support(format, WINED3D_GL_RES_TYPE_TEX_2D, desc->usage) && (gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] || (desc->width == pow2_width && desc->height == pow2_height))) gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
&& (!(desc->usage & WINED3DUSAGE_DEPTHSTENCIL) || (format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] & ds_flags)))
&& check_ds_support(format, WINED3D_GL_RES_TYPE_TEX_RECT, desc->usage)) gl_type = WINED3D_GL_RES_TYPE_TEX_RECT;
- else if ((format->flags[WINED3D_GL_RES_TYPE_RB] & required_flags) == required_flags
&& check_ds_support(format, WINED3D_GL_RES_TYPE_RB, desc->usage))
else gl_type = WINED3D_GL_RES_TYPE_TEX_2D; /* No error, may be SCRATCH pool or emulated conditional np2. */gl_type = WINED3D_GL_RES_TYPE_RB;
This is kind of ok because the existing code is like this, but notice the similarity to some of the code in resource_init(). In fact, is there any reason the caller needs to pass "gl_type" to resource_init() instead of letting it figure it out on its own?
-static void delete_fbo_attachment(const struct wined3d_gl_info *gl_info) +static void delete_fbo_attachment(const struct wined3d_gl_info *gl_info,
enum wined3d_gl_resource_type d3d_type, GLuint *object)
{
- gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0);
- switch (d3d_type)
- {
case WINED3D_GL_RES_TYPE_TEX_1D:
case WINED3D_GL_RES_TYPE_TEX_2D:
case WINED3D_GL_RES_TYPE_TEX_RECT:
case WINED3D_GL_RES_TYPE_TEX_3D:
case WINED3D_GL_RES_TYPE_TEX_CUBE:
gl_info->gl_ops.gl.p_glDeleteTextures(1, object);
break;
case WINED3D_GL_RES_TYPE_RB:
gl_info->fbo_ops.glDeleteRenderbuffers(1, object);
break;
case WINED3D_GL_RES_TYPE_BUFFER:
case WINED3D_GL_RES_TYPE_COUNT:
break;
- }
}
Why is "object" a pointer?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-05-25 um 10:27 schrieb Henri Verbeet:
This is kind of ok because the existing code is like this, but notice the similarity to some of the code in resource_init(). In fact, is there any reason the caller needs to pass "gl_type" to resource_init() instead of letting it figure it out on its own?
The idea is to keep the switch between the different 2D types in the 2D texture init parts of the code instead of the generic code.
-static void delete_fbo_attachment(const struct wined3d_gl_info *gl_info) +static void delete_fbo_attachment(const struct wined3d_gl_info *gl_info,
Why is "object" a pointer?
Symmetry with create_and_bind_fbo_attachment(). But yeah, it's not really necessary, I'll change this.
On 25 May 2015 at 10:43, Stefan Dösinger stefandoesinger@gmail.com wrote:
Am 2015-05-25 um 10:27 schrieb Henri Verbeet:
This is kind of ok because the existing code is like this, but notice the similarity to some of the code in resource_init(). In fact, is there any reason the caller needs to pass "gl_type" to resource_init() instead of letting it figure it out on its own?
The idea is to keep the switch between the different 2D types in the 2D texture init parts of the code instead of the generic code.
I guess, but it doesn't really seem worth it if that means duplicating much of the generic usage/format validation code.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-05-25 um 10:50 schrieb Henri Verbeet:
I guess, but it doesn't really seem worth it if that means duplicating much of the generic usage/format validation code.
I tried to move the code to resource_init and the non power of 2 handling is a big problem. resource_init doesn't care about power of 2 and non power of 2 sizes, and I don't think it should. It would need to know that though to switch between 2D and RECT.
Adding a flag for "this resource type supports NP2 textures" isn't really an option either. If we have neither TEXTURE_NP2 nor TEXTURE_RECTANGLE (some GL ES systems according to Matteo) we want to use 2D textures with padding.
The other relatively minor problem is handling subresources. The solution here is to never set or read the resource type on subresources, which we already do, and don't do capability validation on subresources. Right now we read format flags from subresources though .
On 26 May 2015 at 12:54, Stefan Dösinger stefandoesinger@gmail.com wrote:
I tried to move the code to resource_init and the non power of 2 handling is a big problem. resource_init doesn't care about power of 2 and non power of 2 sizes, and I don't think it should. It would need to know that though to switch between 2D and RECT.
What is the issue exactly?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-05-26 um 13:03 schrieb Henri Verbeet:
On 26 May 2015 at 12:54, Stefan Dösinger stefandoesinger@gmail.com wrote:
I tried to move the code to resource_init and the non power of 2 handling is a big problem. resource_init doesn't care about power of 2 and non power of 2 sizes, and I don't think it should. It would need to know that though to switch between 2D and RECT.
What is the issue exactly?
I'd have to move or duplicate the power of two size calculation (texture.c lines 1092 - 1123) to resource_init, and I don't think the generic resource code should have to deal with this functionality that is very specific to 2D textures. Passing a "this is a np2 texture" flag to resource_init is a possible option, but it would still take quite a bit of 2D texture specific code along with it (in particular the switch between true NP2, faked WINED3D_GL_NORMALIZED_TEXRECT NP2, ARB_texture_rectangle and 2D texture emulated NP2).
I'm not saying we can't do it that way. I just don't think it is nicer. I'll see if I can extract the flag checks into a separate function that texture_init and resource_init can call.
On 26 May 2015 at 13:33, Stefan Dösinger stefandoesinger@gmail.com wrote:
I'd have to move or duplicate the power of two size calculation (texture.c lines 1092 - 1123) to resource_init, and I don't think the generic resource code should have to deal with this functionality that is very specific to 2D textures. Passing a "this is a np2 texture" flag to resource_init is a possible option, but it would still take quite a bit of 2D texture specific code along with it (in particular the switch between true NP2, faked WINED3D_GL_NORMALIZED_TEXRECT NP2, ARB_texture_rectangle and 2D texture emulated NP2).
You don't really need pow2_width/pow2_height itself though, you just need to determine if the resource dimensions are powers of two, which is much easier. (I.e., "!(desc->width & desc->width - 1)", etc.)
2015-05-26 12:54 GMT+02:00 Stefan Dösinger stefandoesinger@gmail.com:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2015-05-25 um 10:50 schrieb Henri Verbeet:
I guess, but it doesn't really seem worth it if that means duplicating much of the generic usage/format validation code.
I tried to move the code to resource_init and the non power of 2 handling is a big problem. resource_init doesn't care about power of 2 and non power of 2 sizes, and I don't think it should. It would need to know that though to switch between 2D and RECT.
Adding a flag for "this resource type supports NP2 textures" isn't really an option either. If we have neither TEXTURE_NP2 nor TEXTURE_RECTANGLE (some GL ES systems according to Matteo) we want to use 2D textures with padding.
Just to clarify on this point, even though it's quite tangential to the discussion: basic GL ES 2 has pretty much the same limitations as a D3D device with D3DPTEXTURECAPS_NONPOW2CONDITIONAL: NP2 textures are supported as long as you use CLAMP_TO_EDGE texcoord wrapping and don't make use of mipmapping in minification filtering. In theory D3D applications should check the cap bit and avoid that kind of usage, except often times they don't. The texture handling stuff related with WINED3D_GL_NORMALIZED_TEXRECT and WINED3D_TEXTURE_COND_NP2 mostly does the right thing here and yeah, it would be nice if that stays around. BTW, rectangle textures are not supported in OpenGL ES.