mirror of
https://github.com/reactos/wine.git
synced 2024-12-04 01:41:18 +00:00
wined3d: Get rid of the redundant texture_name and texture_name_srgb fields in struct wined3d_surface.
This commit is contained in:
parent
e64b19387b
commit
7e8897b7b8
@ -146,7 +146,7 @@ static void context_attach_depth_stencil_fbo(struct wined3d_context *context,
|
||||
if (format_flags & WINED3DFMT_FLAG_DEPTH)
|
||||
{
|
||||
gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_DEPTH_ATTACHMENT,
|
||||
depth_stencil->texture_target, depth_stencil->texture_name,
|
||||
depth_stencil->texture_target, depth_stencil->container->texture_rgb.name,
|
||||
depth_stencil->texture_level);
|
||||
checkGLcall("glFramebufferTexture2D()");
|
||||
}
|
||||
@ -154,7 +154,7 @@ static void context_attach_depth_stencil_fbo(struct wined3d_context *context,
|
||||
if (format_flags & WINED3DFMT_FLAG_STENCIL)
|
||||
{
|
||||
gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_STENCIL_ATTACHMENT,
|
||||
depth_stencil->texture_target, depth_stencil->texture_name,
|
||||
depth_stencil->texture_target, depth_stencil->container->texture_rgb.name,
|
||||
depth_stencil->texture_level);
|
||||
checkGLcall("glFramebufferTexture2D()");
|
||||
}
|
||||
@ -2939,7 +2939,7 @@ static void context_setup_target(struct wined3d_context *context, struct wined3d
|
||||
&& old_render_offscreen && context->current_rt != target)
|
||||
{
|
||||
/* Read the back buffer of the old drawable into the destination texture. */
|
||||
if (context->current_rt->texture_name_srgb)
|
||||
if (context->current_rt->container->texture_srgb.name)
|
||||
surface_internal_preload(context->current_rt, context, SRGB_SRGB);
|
||||
surface_internal_preload(context->current_rt, context, SRGB_RGB);
|
||||
surface_invalidate_location(context->current_rt, SFLAG_INDRAWABLE);
|
||||
|
@ -42,9 +42,8 @@ static void surface_cleanup(struct wined3d_surface *surface)
|
||||
|
||||
TRACE("surface %p.\n", surface);
|
||||
|
||||
if (surface->texture_name || (surface->flags & SFLAG_PBO)
|
||||
|| surface->rb_multisample || surface->rb_resolved
|
||||
|| !list_empty(&surface->renderbuffers))
|
||||
if ((surface->flags & SFLAG_PBO) || surface->rb_multisample
|
||||
|| surface->rb_resolved || !list_empty(&surface->renderbuffers))
|
||||
{
|
||||
struct wined3d_renderbuffer_entry *entry, *entry2;
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
@ -53,12 +52,6 @@ static void surface_cleanup(struct wined3d_surface *surface)
|
||||
context = context_acquire(surface->resource.device, NULL);
|
||||
gl_info = context->gl_info;
|
||||
|
||||
if (surface->texture_name)
|
||||
{
|
||||
TRACE("Deleting texture %u.\n", surface->texture_name);
|
||||
gl_info->gl_ops.gl.p_glDeleteTextures(1, &surface->texture_name);
|
||||
}
|
||||
|
||||
if (surface->flags & SFLAG_PBO)
|
||||
{
|
||||
TRACE("Deleting PBO %u.\n", surface->pbo);
|
||||
@ -341,7 +334,7 @@ void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3
|
||||
gl_info->gl_ops.gl.p_glEnable(info.bind_target);
|
||||
checkGLcall("glEnable(bind_target)");
|
||||
|
||||
context_bind_texture(context, info.bind_target, src_surface->texture_name);
|
||||
context_bind_texture(context, info.bind_target, texture->texture_rgb.name);
|
||||
|
||||
/* Filtering for StretchRect */
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAG_FILTER,
|
||||
@ -644,13 +637,13 @@ static void surface_release_client_storage(struct wined3d_surface *surface)
|
||||
struct wined3d_context *context = context_acquire(surface->resource.device, NULL);
|
||||
const struct wined3d_gl_info *gl_info = context->gl_info;
|
||||
|
||||
if (surface->texture_name)
|
||||
if (surface->container->texture_rgb.name)
|
||||
{
|
||||
surface_bind_and_dirtify(surface, context, FALSE);
|
||||
gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level,
|
||||
GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
if (surface->texture_name_srgb)
|
||||
if (surface->container->texture_srgb.name)
|
||||
{
|
||||
surface_bind_and_dirtify(surface, context, TRUE);
|
||||
gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level,
|
||||
@ -671,7 +664,6 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface)
|
||||
|
||||
TRACE("surface %p.\n", surface);
|
||||
|
||||
surface->texture_name = 0;
|
||||
surface->texture_target = GL_TEXTURE_2D;
|
||||
|
||||
/* Non-power2 support */
|
||||
@ -1642,18 +1634,6 @@ static const struct wined3d_surface_ops gdi_surface_ops =
|
||||
gdi_surface_unmap,
|
||||
};
|
||||
|
||||
void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb)
|
||||
{
|
||||
TRACE("surface %p, name %u, srgb %#x.\n", surface, name, srgb);
|
||||
|
||||
if (srgb)
|
||||
surface->texture_name_srgb = name;
|
||||
else
|
||||
surface->texture_name = name;
|
||||
|
||||
surface_force_reload(surface);
|
||||
}
|
||||
|
||||
void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level)
|
||||
{
|
||||
TRACE("surface %p, target %#x.\n", surface, target);
|
||||
@ -4251,14 +4231,6 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back)
|
||||
{
|
||||
GLuint tmp;
|
||||
|
||||
tmp = back->texture_name;
|
||||
back->texture_name = front->texture_name;
|
||||
front->texture_name = tmp;
|
||||
|
||||
tmp = back->texture_name_srgb;
|
||||
back->texture_name_srgb = front->texture_name_srgb;
|
||||
front->texture_name_srgb = tmp;
|
||||
|
||||
tmp = back->rb_multisample;
|
||||
back->rb_multisample = front->rb_multisample;
|
||||
front->rb_multisample = tmp;
|
||||
@ -4306,7 +4278,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
|
||||
surface_internal_preload(dst_surface, context, SRGB_RGB);
|
||||
|
||||
/* Bind the target texture */
|
||||
context_bind_texture(context, dst_surface->container->target, dst_surface->texture_name);
|
||||
context_bind_texture(context, dst_surface->container->target, dst_surface->container->texture_rgb.name);
|
||||
if (surface_is_offscreen(src_surface))
|
||||
{
|
||||
TRACE("Reading from an offscreen target\n");
|
||||
@ -4415,7 +4387,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||
|
||||
src_offscreen = surface_is_offscreen(src_surface);
|
||||
noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
|
||||
if (!noBackBufferBackup && !src_surface->texture_name)
|
||||
if (!noBackBufferBackup && !src_surface->container->texture_rgb.name)
|
||||
{
|
||||
/* Get it a description */
|
||||
surface_internal_preload(src_surface, context, SRGB_RGB);
|
||||
@ -4448,7 +4420,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||
* we are reading from the back buffer, the backup can be used as source texture
|
||||
*/
|
||||
texture_target = src_surface->texture_target;
|
||||
context_bind_texture(context, texture_target, src_surface->texture_name);
|
||||
context_bind_texture(context, texture_target, src_surface->container->texture_rgb.name);
|
||||
gl_info->gl_ops.gl.p_glEnable(texture_target);
|
||||
checkGLcall("glEnable(texture_target)");
|
||||
|
||||
@ -4492,7 +4464,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||
|
||||
if (!src_surface->swapchain || src_surface == src_surface->swapchain->back_buffers[0])
|
||||
{
|
||||
src = backup ? backup : src_surface->texture_name;
|
||||
src = backup ? backup : src_surface->container->texture_rgb.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4584,7 +4556,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||
}
|
||||
|
||||
/* Now read the stretched and upside down image into the destination texture */
|
||||
context_bind_texture(context, texture_target, dst_surface->texture_name);
|
||||
context_bind_texture(context, texture_target, dst_surface->container->texture_rgb.name);
|
||||
gl_info->gl_ops.gl.p_glCopyTexSubImage2D(texture_target,
|
||||
0,
|
||||
dst_rect.left, dst_rect.top, /* xoffset, yoffset */
|
||||
@ -4613,7 +4585,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||
gl_info->gl_ops.gl.p_glEnable(src_surface->texture_target);
|
||||
texture_target = src_surface->texture_target;
|
||||
}
|
||||
context_bind_texture(context, src_surface->texture_target, src_surface->texture_name);
|
||||
context_bind_texture(context, src_surface->texture_target, src_surface->container->texture_rgb.name);
|
||||
}
|
||||
|
||||
gl_info->gl_ops.gl.p_glBegin(GL_QUADS);
|
||||
@ -4639,7 +4611,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||
checkGLcall("glDisable(texture_target)");
|
||||
|
||||
/* Cleanup */
|
||||
if (src != src_surface->texture_name && src != backup)
|
||||
if (src != src_surface->container->texture_rgb.name && src != backup)
|
||||
{
|
||||
gl_info->gl_ops.gl.p_glDeleteTextures(1, &src);
|
||||
checkGLcall("glDeleteTextures(1, &src)");
|
||||
@ -5174,7 +5146,7 @@ void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_co
|
||||
|
||||
context_apply_fbo_state_blit(context, GL_FRAMEBUFFER,
|
||||
context->swapchain->front_buffer, NULL, SFLAG_INDRAWABLE);
|
||||
surface_depth_blt(surface, context, surface->texture_name,
|
||||
surface_depth_blt(surface, context, surface->container->texture_rgb.name,
|
||||
0, surface->pow2Height - h, w, h, surface->texture_target);
|
||||
checkGLcall("depth_blt");
|
||||
|
||||
|
@ -352,7 +352,7 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
|
||||
gl_filter = GL_NEAREST;
|
||||
|
||||
context_apply_fbo_state_blit(context2, GL_FRAMEBUFFER, swapchain->front_buffer, NULL, SFLAG_INDRAWABLE);
|
||||
context_bind_texture(context2, backbuffer->texture_target, backbuffer->texture_name);
|
||||
context_bind_texture(context2, backbuffer->texture_target, backbuffer->container->texture_rgb.name);
|
||||
|
||||
/* Set up the texture. The surface is not in a wined3d_texture
|
||||
* container, so there are no D3D texture settings to dirtify. */
|
||||
|
@ -610,21 +610,12 @@ static HRESULT texture2d_bind(struct wined3d_texture *texture,
|
||||
|
||||
TRACE("texture %p, context %p, srgb %#x.\n", texture, context, srgb);
|
||||
|
||||
hr = wined3d_texture_bind(texture, context, srgb, &set_gl_texture_desc);
|
||||
if (set_gl_texture_desc && SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr = wined3d_texture_bind(texture, context, srgb, &set_gl_texture_desc))
|
||||
&& set_gl_texture_desc && (texture->flags & WINED3D_TEXTURE_COND_NP2))
|
||||
{
|
||||
UINT sub_count = texture->level_count * texture->layer_count;
|
||||
BOOL srgb_tex = texture->flags & WINED3D_TEXTURE_IS_SRGB;
|
||||
struct gl_texture *gl_tex;
|
||||
UINT i;
|
||||
|
||||
gl_tex = wined3d_texture_get_gl_texture(texture, srgb_tex);
|
||||
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
struct wined3d_surface *surface = surface_from_resource(texture->sub_resources[i]);
|
||||
surface_set_texture_name(surface, gl_tex->name, srgb_tex);
|
||||
}
|
||||
struct gl_texture *gl_tex = wined3d_texture_get_gl_texture(texture,
|
||||
texture->flags & WINED3D_TEXTURE_IS_SRGB);
|
||||
GLenum target = texture->target;
|
||||
|
||||
/* Conditinal non power of two textures use a different clamping
|
||||
* default. If we're using the GL_WINE_normalized_texrect partial
|
||||
@ -634,24 +625,19 @@ static HRESULT texture2d_bind(struct wined3d_texture *texture,
|
||||
* state. The same applies to filtering. Even if the texture has only
|
||||
* one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW
|
||||
* fallback on macos. */
|
||||
if (texture->flags & WINED3D_TEXTURE_COND_NP2)
|
||||
{
|
||||
GLenum target = texture->target;
|
||||
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3D_TADDRESS_CLAMP;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3D_TADDRESS_CLAMP;
|
||||
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3D_TEXF_POINT;
|
||||
gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3D_TEXF_POINT;
|
||||
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3D_TEXF_NONE;
|
||||
}
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
|
||||
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
checkGLcall("glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3D_TADDRESS_CLAMP;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3D_TADDRESS_CLAMP;
|
||||
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3D_TEXF_POINT;
|
||||
gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3D_TEXF_POINT;
|
||||
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3D_TEXF_NONE;
|
||||
}
|
||||
|
||||
return hr;
|
||||
@ -717,10 +703,6 @@ static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource
|
||||
{
|
||||
struct wined3d_surface *surface = surface_from_resource(sub_resource);
|
||||
|
||||
/* Clean out the texture name we gave to the surface so that the
|
||||
* surface doesn't try and release it. */
|
||||
surface_set_texture_name(surface, 0, TRUE);
|
||||
surface_set_texture_name(surface, 0, FALSE);
|
||||
surface_set_texture_target(surface, 0, 0);
|
||||
surface_set_container(surface, NULL);
|
||||
wined3d_surface_decref(surface);
|
||||
@ -737,11 +719,8 @@ static void texture2d_unload(struct wined3d_resource *resource)
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
struct wined3d_resource *sub_resource = texture->sub_resources[i];
|
||||
struct wined3d_surface *surface = surface_from_resource(sub_resource);
|
||||
|
||||
sub_resource->resource_ops->resource_unload(sub_resource);
|
||||
surface_set_texture_name(surface, 0, FALSE); /* Delete RGB name */
|
||||
surface_set_texture_name(surface, 0, TRUE); /* Delete sRGB name */
|
||||
}
|
||||
|
||||
wined3d_texture_unload(texture);
|
||||
|
@ -2198,8 +2198,6 @@ struct wined3d_surface
|
||||
GLuint pbo;
|
||||
GLuint rb_multisample;
|
||||
GLuint rb_resolved;
|
||||
GLuint texture_name;
|
||||
GLuint texture_name_srgb;
|
||||
GLint texture_level;
|
||||
GLenum texture_target;
|
||||
|
||||
@ -2241,7 +2239,7 @@ static inline GLuint surface_get_texture_name(const struct wined3d_surface *surf
|
||||
const struct wined3d_gl_info *gl_info, BOOL srgb)
|
||||
{
|
||||
return srgb && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
|
||||
? surface->texture_name_srgb : surface->texture_name;
|
||||
? surface->container->texture_srgb.name : surface->container->texture_rgb.name;
|
||||
}
|
||||
|
||||
void surface_add_dirty_rect(struct wined3d_surface *surface, const struct wined3d_box *dirty_rect) DECLSPEC_HIDDEN;
|
||||
@ -2266,7 +2264,6 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
|
||||
const struct wined3d_surface *rt) DECLSPEC_HIDDEN;
|
||||
void surface_set_container(struct wined3d_surface *surface, struct wined3d_texture *container) DECLSPEC_HIDDEN;
|
||||
void surface_set_swapchain(struct wined3d_surface *surface, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
|
||||
void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
|
||||
void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN;
|
||||
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
|
||||
void surface_update_draw_binding(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
|
||||
|
Loading…
Reference in New Issue
Block a user