wined3d: Pass a wined3d_context_gl structure to context_bind_texture().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-05-07 15:00:11 +04:30 committed by Alexandre Julliard
parent 5ab6421dfe
commit 6de1837955
6 changed files with 43 additions and 30 deletions

View File

@ -2528,22 +2528,20 @@ void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint nam
GL_EXTCALL(glBindBuffer(binding, name));
}
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLenum target, GLuint name)
{
const struct wined3d_dummy_textures *textures = &wined3d_device_gl(context->device)->dummy_textures;
const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD unit = context->active_texture;
DWORD old_texture_type = context->texture_type[unit];
const struct wined3d_dummy_textures *textures = &wined3d_device_gl(context_gl->c.device)->dummy_textures;
const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
GLenum old_texture_type;
unsigned int unit;
if (name)
{
gl_info->gl_ops.gl.p_glBindTexture(target, name);
}
else
{
target = GL_NONE;
}
unit = context_gl->c.active_texture;
old_texture_type = context_gl->c.texture_type[unit];
if (old_texture_type != target)
{
switch (old_texture_type)
@ -2588,7 +2586,7 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint
ERR("Unexpected texture target %#x.\n", old_texture_type);
}
context->texture_type[unit] = target;
context_gl->c.texture_type[unit] = target;
}
checkGLcall("bind texture");
@ -5558,6 +5556,7 @@ void context_draw_shaded_quad(struct wined3d_context *context, struct wined3d_te
unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
enum wined3d_texture_filter_type filter)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_blt_info info;
unsigned int level, w, h, i;
@ -5572,7 +5571,7 @@ void context_draw_shaded_quad(struct wined3d_context *context, struct wined3d_te
texture2d_get_blt_info(texture_gl, sub_resource_idx, src_rect, &info);
level = sub_resource_idx % texture_gl->t.level_count;
context_bind_texture(context, info.bind_target, texture_gl->texture_rgb.name);
wined3d_context_gl_bind_texture(context_gl, info.bind_target, texture_gl->texture_rgb.name);
apply_texture_blit_state(gl_info, &texture_gl->texture_rgb, info.bind_target, level, filter);
gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, level);
@ -5635,7 +5634,7 @@ void context_draw_shaded_quad(struct wined3d_context *context, struct wined3d_te
checkGLcall("draw");
gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1);
context_bind_texture(context, info.bind_target, 0);
wined3d_context_gl_bind_texture(context_gl, info.bind_target, 0);
}
/* Context activation is done by the caller. */
@ -5643,6 +5642,7 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_
unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
enum wined3d_texture_filter_type filter)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_blt_info info;
unsigned int level;
@ -5653,7 +5653,7 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_
checkGLcall("glEnable(bind_target)");
level = sub_resource_idx % texture_gl->t.level_count;
context_bind_texture(context, info.bind_target, texture_gl->texture_rgb.name);
wined3d_context_gl_bind_texture(context_gl, info.bind_target, texture_gl->texture_rgb.name);
apply_texture_blit_state(gl_info, &texture_gl->texture_rgb, info.bind_target, level, filter);
gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, level);
gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@ -5675,5 +5675,5 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_
gl_info->gl_ops.gl.p_glEnd();
gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1);
context_bind_texture(context, info.bind_target, 0);
wined3d_context_gl_bind_texture(context_gl, info.bind_target, 0);
}

View File

@ -3596,6 +3596,7 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
* texture states. */
static void sampler(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
DWORD sampler_idx = state_id - STATE_SAMPLER(0);
DWORD mapped_stage = context->tex_unit_map[sampler_idx];
const struct wined3d_gl_info *gl_info = context->gl_info;
@ -3653,7 +3654,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
}
else
{
context_bind_texture(context, GL_NONE, 0);
wined3d_context_gl_bind_texture(context_gl, GL_NONE, 0);
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
{
GL_EXTCALL(glBindSampler(mapped_stage, 0));

View File

@ -888,6 +888,7 @@ static void fb_copy_to_texture_direct(struct wined3d_texture_gl *dst_texture, un
struct wined3d_device *device = dst_texture->t.resource.device;
unsigned int src_height, src_level, dst_level;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
float xrel, yrel;
struct wined3d_context *context;
BOOL upsidedown = FALSE;
@ -905,12 +906,13 @@ static void fb_copy_to_texture_direct(struct wined3d_texture_gl *dst_texture, un
}
context = context_acquire(device, &src_texture->t, src_sub_resource_idx);
context_gl = wined3d_context_gl(context);
gl_info = context->gl_info;
context_apply_blit_state(context, device);
wined3d_texture_load(&dst_texture->t, context, FALSE);
/* Bind the target texture */
context_bind_texture(context, dst_texture->target, dst_texture->texture_rgb.name);
wined3d_context_gl_bind_texture(context_gl, dst_texture->target, dst_texture->texture_rgb.name);
if (wined3d_resource_is_offscreen(&src_texture->t.resource))
{
TRACE("Reading from an offscreen target\n");
@ -1008,6 +1010,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
GLuint src, backup = 0;
float left, right, top, bottom; /* Texture coordinates */
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
struct wined3d_context *context;
GLenum drawBuffer = GL_BACK;
GLenum offscreen_buffer;
@ -1023,6 +1026,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
/* Activate the Proper context for reading from the source surface, set it up for blitting */
context = context_acquire(device, &src_texture->t, src_sub_resource_idx);
context_gl = wined3d_context_gl(context);
gl_info = context->gl_info;
context_apply_ffp_blit_state(context, device);
wined3d_texture_load(&dst_texture->t, context, FALSE);
@ -1060,7 +1064,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
{
gl_info->gl_ops.gl.p_glGenTextures(1, &backup);
checkGLcall("glGenTextures");
context_bind_texture(context, GL_TEXTURE_2D, backup);
wined3d_context_gl_bind_texture(context_gl, GL_TEXTURE_2D, backup);
texture_target = GL_TEXTURE_2D;
}
else
@ -1069,7 +1073,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
* we are reading from the back buffer, the backup can be used as source texture
*/
texture_target = src_target;
context_bind_texture(context, texture_target, src_texture->texture_rgb.name);
wined3d_context_gl_bind_texture(context_gl, texture_target, src_texture->texture_rgb.name);
gl_info->gl_ops.gl.p_glEnable(texture_target);
checkGLcall("glEnable(texture_target)");
@ -1121,7 +1125,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
gl_info->gl_ops.gl.p_glGenTextures(1, &src);
checkGLcall("glGenTextures(1, &src)");
context_bind_texture(context, GL_TEXTURE_2D, src);
wined3d_context_gl_bind_texture(context_gl, 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
@ -1204,7 +1208,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
}
/* Now read the stretched and upside down image into the destination texture */
context_bind_texture(context, texture_target, dst_texture->texture_rgb.name);
wined3d_context_gl_bind_texture(context_gl, texture_target, dst_texture->texture_rgb.name);
gl_info->gl_ops.gl.p_glCopyTexSubImage2D(texture_target,
0,
dst_rect.left, dst_rect.top, /* xoffset, yoffset */
@ -1223,7 +1227,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D);
texture_target = GL_TEXTURE_2D;
}
context_bind_texture(context, GL_TEXTURE_2D, backup);
wined3d_context_gl_bind_texture(context_gl, GL_TEXTURE_2D, backup);
}
else
{
@ -1233,7 +1237,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
gl_info->gl_ops.gl.p_glEnable(src_target);
texture_target = src_target;
}
context_bind_texture(context, src_target, src_texture->texture_rgb.name);
wined3d_context_gl_bind_texture(context_gl, src_target, src_texture->texture_rgb.name);
}
gl_info->gl_ops.gl.p_glBegin(GL_QUADS);

View File

@ -928,6 +928,7 @@ void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_
void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
struct wined3d_context *context, BOOL srgb)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_format *format = texture_gl->t.resource.format;
const struct color_fixup_desc fixup = format->color_fixup;
const struct wined3d_gl_info *gl_info = context->gl_info;
@ -950,7 +951,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
if (gl_tex->name)
{
context_bind_texture(context, target, gl_tex->name);
wined3d_context_gl_bind_texture(context_gl, target, gl_tex->name);
return;
}
@ -986,7 +987,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
gl_tex->base_level = 0;
wined3d_texture_set_dirty(&texture_gl->t);
context_bind_texture(context, target, gl_tex->name);
wined3d_context_gl_bind_texture(context_gl, target, gl_tex->name);
/* For a new texture we have to set the texture levels after binding the
* texture. Beware that texture rectangles do not support mipmapping, but

View File

@ -172,6 +172,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
const struct wined3d_format_gl *view_format_gl;
unsigned int level_idx, layer_idx, layer_count;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
struct wined3d_context *context;
GLuint texture_name;
@ -179,6 +180,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
view->target = view_target;
context = context_acquire(texture_gl->t.resource.device, NULL, 0);
context_gl = wined3d_context_gl(context);
gl_info = context->gl_info;
if (!gl_info->supported[ARB_TEXTURE_VIEW])
@ -218,7 +220,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
return;
}
context_bind_texture(context, view->target, view->name);
wined3d_context_gl_bind_texture(context_gl, view->target, view->name);
gl_info->gl_ops.gl.p_glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
gl_info->gl_ops.gl.p_glTexParameteri(view->target, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
checkGLcall("initialize stencil view");
@ -230,7 +232,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
{
GLint swizzle[4];
context_bind_texture(context, view->target, view->name);
wined3d_context_gl_bind_texture(context_gl, view->target, view->name);
wined3d_gl_texture_swizzle_from_color_fixup(swizzle, view_format->color_fixup);
gl_info->gl_ops.gl.p_glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
checkGLcall("set format swizzle");
@ -246,6 +248,7 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c
struct wined3d_buffer *buffer, const struct wined3d_format *view_format,
unsigned int offset, unsigned int size)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_format_gl *view_format_gl;
@ -268,7 +271,7 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c
view->target = GL_TEXTURE_BUFFER;
gl_info->gl_ops.gl.p_glGenTextures(1, &view->name);
context_bind_texture(context, GL_TEXTURE_BUFFER, view->name);
wined3d_context_gl_bind_texture(context_gl, GL_TEXTURE_BUFFER, view->name);
if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
{
GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format_gl->internal,
@ -827,6 +830,7 @@ HRESULT CDECL wined3d_shader_resource_view_create(const struct wined3d_view_desc
void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl,
unsigned int unit, struct wined3d_sampler *sampler, struct wined3d_context *context)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture_gl *texture_gl;
@ -834,7 +838,7 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
if (view_gl->gl_view.name)
{
context_bind_texture(context, view_gl->gl_view.target, view_gl->gl_view.name);
wined3d_context_gl_bind_texture(context_gl, view_gl->gl_view.target, view_gl->gl_view.name);
wined3d_sampler_bind(sampler, unit, NULL, context);
return;
}
@ -854,6 +858,8 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resource_view_gl *view_gl,
struct wined3d_context *context)
{
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
if (context->active_texture < ARRAY_SIZE(context->rev_tex_unit_map))
{
DWORD active_sampler = context->rev_tex_unit_map[context->active_texture];
@ -865,7 +871,7 @@ static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resou
context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
context_bind_texture(context, view_gl->gl_view.target, view_gl->gl_view.name);
wined3d_context_gl_bind_texture(context_gl, view_gl->gl_view.target, view_gl->gl_view.name);
}
void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view)

View File

@ -2045,6 +2045,8 @@ static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_conte
return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
}
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
GLenum target, GLuint name) DECLSPEC_HIDDEN;
void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
@ -2204,7 +2206,6 @@ void context_active_texture(struct wined3d_context *context, const struct wined3
unsigned int unit) DECLSPEC_HIDDEN;
void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
void context_bind_dummy_textures(const struct wined3d_context *context) 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;
void context_copy_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *dst, GLenum dst_binding,