Commit 0386b44b authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Keep track of the current texture type for each texture unit.

parent ac1a0d96
......@@ -7234,7 +7234,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
ENTER_GL();
/* Draw a textured quad */
draw_textured_quad(src_surface, src_rect, &dst_rect, filter);
draw_textured_quad(src_surface, context, src_rect, &dst_rect, filter);
LEAVE_GL();
......
......@@ -1909,6 +1909,16 @@ void context_active_texture(struct wined3d_context *context, const struct wined3
context->active_texture = unit;
}
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
{
glBindTexture(target, name);
checkGLcall("glBindTexture");
if (name)
context->texture_type[context->active_texture] = target;
else
context->texture_type[context->active_texture] = GL_NONE;
}
static void context_set_render_offscreen(struct wined3d_context *context, BOOL offscreen)
{
if (context->render_offscreen == offscreen) return;
......
......@@ -5281,8 +5281,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
/* Create a new cursor texture */
glGenTextures(1, &device->cursorTexture);
checkGLcall("glGenTextures");
glBindTexture(GL_TEXTURE_2D, device->cursorTexture);
checkGLcall("glBindTexture");
context_bind_texture(context, GL_TEXTURE_2D, device->cursorTexture);
/* Copy the bitmap memory into the cursor texture */
glTexImage2D(GL_TEXTURE_2D, 0, intfmt, width, height, 0, gl_format, type, mem);
checkGLcall("glTexImage2D");
......
......@@ -3578,8 +3578,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
state_alpha(context, state, WINED3DRS_COLORKEYENABLE);
}
} /* Otherwise tex_colorop disables the stage */
glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler]);
checkGLcall("glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler])");
context_bind_texture(context, GL_TEXTURE_2D, device->dummyTextureName[sampler]);
}
}
......
......@@ -311,8 +311,8 @@ static void surface_get_rect(const struct wined3d_surface *surface, const RECT *
}
/* GL locking and context activation is done by the caller */
void draw_textured_quad(const struct wined3d_surface *src_surface, const RECT *src_rect,
const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter)
void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3d_context *context,
const RECT *src_rect, const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter)
{
struct blt_info info;
......@@ -321,9 +321,7 @@ void draw_textured_quad(const struct wined3d_surface *src_surface, const RECT *s
glEnable(info.bind_target);
checkGLcall("glEnable(bind_target)");
/* Bind the texture */
glBindTexture(info.bind_target, src_surface->texture_name);
checkGLcall("glBindTexture");
context_bind_texture(context, info.bind_target, src_surface->texture_name);
/* Filtering for StretchRect */
glTexParameteri(info.bind_target, GL_TEXTURE_MAG_FILTER,
......@@ -353,8 +351,7 @@ void draw_textured_quad(const struct wined3d_surface *src_surface, const RECT *s
glEnd();
/* Unbind the texture */
glBindTexture(info.bind_target, 0);
checkGLcall("glBindTexture(info->bind_target, 0)");
context_bind_texture(context, info.bind_target, 0);
/* We changed the filtering settings on the texture. Inform the
* container about this to get the filters reset properly next draw. */
......@@ -2275,8 +2272,7 @@ void surface_bind(struct wined3d_surface *surface, struct wined3d_context *conte
TRACE("Surface %p given name %u.\n", surface, surface->texture_name);
glBindTexture(surface->texture_target, surface->texture_name);
checkGLcall("glBindTexture");
context_bind_texture(context, surface->texture_target, surface->texture_name);
glTexParameteri(surface->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(surface->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(surface->texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
......@@ -2286,8 +2282,7 @@ void surface_bind(struct wined3d_surface *surface, struct wined3d_context *conte
}
else
{
glBindTexture(surface->texture_target, surface->texture_name);
checkGLcall("glBindTexture");
context_bind_texture(context, surface->texture_target, surface->texture_name);
}
LEAVE_GL();
......@@ -4867,8 +4862,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
ENTER_GL();
/* Bind the target texture */
glBindTexture(dst_surface->texture_target, dst_surface->texture_name);
checkGLcall("glBindTexture");
context_bind_texture(context, dst_surface->texture_target, dst_surface->texture_name);
if (surface_is_offscreen(src_surface))
{
TRACE("Reading from an offscreen target\n");
......@@ -5002,16 +4996,14 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
if(noBackBufferBackup) {
glGenTextures(1, &backup);
checkGLcall("glGenTextures");
glBindTexture(GL_TEXTURE_2D, backup);
checkGLcall("glBindTexture(GL_TEXTURE_2D, backup)");
context_bind_texture(context, GL_TEXTURE_2D, backup);
texture_target = GL_TEXTURE_2D;
} else {
/* Backup the back buffer and copy the source buffer into a texture to draw an upside down stretched quad. If
* we are reading from the back buffer, the backup can be used as source texture
*/
texture_target = src_surface->texture_target;
glBindTexture(texture_target, src_surface->texture_name);
checkGLcall("glBindTexture(texture_target, src_surface->texture_name)");
context_bind_texture(context, texture_target, src_surface->texture_name);
glEnable(texture_target);
checkGLcall("glEnable(texture_target)");
......@@ -5070,8 +5062,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
glGenTextures(1, &src);
checkGLcall("glGenTextures(1, &src)");
glBindTexture(GL_TEXTURE_2D, src);
checkGLcall("glBindTexture(GL_TEXTURE_2D, src)");
context_bind_texture(context, GL_TEXTURE_2D, src);
/* TODO: Only copy the part that will be read. Use src_rect->left, src_rect->bottom as origin, but with the width watch
* out for power of 2 sizes
......@@ -5157,8 +5148,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 */
glBindTexture(texture_target, dst_surface->texture_name);
checkGLcall("glBindTexture");
context_bind_texture(context, texture_target, dst_surface->texture_name);
glCopyTexSubImage2D(texture_target,
0,
dst_rect.left, dst_rect.top, /* xoffset, yoffset */
......@@ -5174,8 +5164,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
glEnable(GL_TEXTURE_2D);
texture_target = GL_TEXTURE_2D;
}
glBindTexture(GL_TEXTURE_2D, backup);
checkGLcall("glBindTexture(GL_TEXTURE_2D, backup)");
context_bind_texture(context, GL_TEXTURE_2D, backup);
}
else
{
......@@ -5185,8 +5174,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
glEnable(src_surface->texture_target);
texture_target = src_surface->texture_target;
}
glBindTexture(src_surface->texture_target, src_surface->texture_name);
checkGLcall("glBindTexture(src_surface->texture_target, src_surface->texture_name)");
context_bind_texture(context, src_surface->texture_target, src_surface->texture_name);
}
glBegin(GL_QUADS);
......@@ -5311,7 +5299,7 @@ static void surface_blt_to_drawable(struct wined3d_device *device,
checkGLcall("glDisable(GL_ALPHA_TEST)");
}
draw_textured_quad(src_surface, &src_rect, &dst_rect, filter);
draw_textured_quad(src_surface, context, &src_rect, &dst_rect, filter);
if (color_key)
{
......
......@@ -189,8 +189,7 @@ static HRESULT wined3d_texture_bind(struct wined3d_texture *texture,
/* This means double binding the texture at creation, but keeps
* the code simpler all in all, and the run-time path free from
* additional checks. */
glBindTexture(target, gl_tex->name);
checkGLcall("glBindTexture");
context_bind_texture(context, target, gl_tex->name);
glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
}
......@@ -202,8 +201,7 @@ static HRESULT wined3d_texture_bind(struct wined3d_texture *texture,
if (gl_tex->name)
{
glBindTexture(target, gl_tex->name);
checkGLcall("glBindTexture");
context_bind_texture(context, target, gl_tex->name);
if (new_texture)
{
/* For a new texture we have to set the texture levels after
......
......@@ -1089,6 +1089,7 @@ struct wined3d_context
UINT blit_w, blit_h;
enum fogsource fog_source;
DWORD active_texture;
DWORD texture_type[MAX_COMBINED_SAMPLERS];
char *vshader_const_dirty, *pshader_const_dirty;
......@@ -1237,6 +1238,7 @@ void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target
struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location) DECLSPEC_HIDDEN;
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info,
unsigned int unit) DECLSPEC_HIDDEN;
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name) DECLSPEC_HIDDEN;
void context_check_fbo_status(const struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN;
struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_surface *target,
const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
......@@ -2098,8 +2100,8 @@ void get_drawable_size_swapchain(const struct wined3d_context *context, UINT *wi
void get_drawable_size_backbuffer(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_fbo(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void draw_textured_quad(const struct wined3d_surface *src_surface, const RECT *src_rect,
const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3d_context *context,
const RECT *src_rect, const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) DECLSPEC_HIDDEN;
/* Surface flags: */
......
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