Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/arb_program_shader.c | 29 +++--- dlls/wined3d/context.c | 6 +- dlls/wined3d/cs.c | 2 +- dlls/wined3d/glsl_shader.c | 25 +++--- dlls/wined3d/nvidia_texture_shader.c | 7 +- dlls/wined3d/sampler.c | 2 +- dlls/wined3d/shader.c | 8 +- dlls/wined3d/state.c | 30 ++++--- dlls/wined3d/surface.c | 64 +++++++------ dlls/wined3d/texture.c | 169 +++++++++++++++++------------------ dlls/wined3d/utils.c | 10 +-- dlls/wined3d/view.c | 28 +++--- dlls/wined3d/wined3d_private.h | 43 ++++----- 13 files changed, 213 insertions(+), 210 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 24f7e045fc5..62118fe0c6d 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7542,7 +7542,7 @@ static GLuint arbfp_gen_plain_shader(const struct wined3d_gl_info *gl_info, cons
/* Context activation is done by the caller. */ static HRESULT arbfp_blit_set(struct wined3d_arbfp_blitter *blitter, struct wined3d_context *context, - const struct wined3d_texture *texture, unsigned int sub_resource_idx, + const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const struct wined3d_color_key *color_key) { enum complex_fixup fixup; @@ -7555,18 +7555,18 @@ static HRESULT arbfp_blit_set(struct wined3d_arbfp_blitter *blitter, struct wine unsigned int level; GLuint shader;
- level = sub_resource_idx % texture->level_count; - size.x = wined3d_texture_get_level_pow2_width(texture, level); - size.y = wined3d_texture_get_level_pow2_height(texture, level); + level = sub_resource_idx % texture_gl->t.level_count; + size.x = wined3d_texture_get_level_pow2_width(&texture_gl->t, level); + size.y = wined3d_texture_get_level_pow2_height(&texture_gl->t, level); size.z = 1.0f; size.w = 1.0f;
- if (is_complex_fixup(texture->resource.format->color_fixup)) - fixup = get_complex_fixup(texture->resource.format->color_fixup); + if (is_complex_fixup(texture_gl->t.resource.format->color_fixup)) + fixup = get_complex_fixup(texture_gl->t.resource.format->color_fixup); else fixup = COMPLEX_FIXUP_NONE;
- switch (texture->target) + switch (texture_gl->target) { case GL_TEXTURE_1D: type.res_type = WINED3D_GL_RES_TYPE_TEX_1D; @@ -7589,7 +7589,7 @@ static HRESULT arbfp_blit_set(struct wined3d_arbfp_blitter *blitter, struct wine break;
default: - ERR("Unexpected GL texture type %#x.\n", texture->target); + ERR("Unexpected GL texture type %#x.\n", texture_gl->target); type.res_type = WINED3D_GL_RES_TYPE_TEX_2D; } type.fixup = fixup; @@ -7606,7 +7606,7 @@ static HRESULT arbfp_blit_set(struct wined3d_arbfp_blitter *blitter, struct wine switch (fixup) { case COMPLEX_FIXUP_NONE: - if (!is_identity_fixup(texture->resource.format->color_fixup)) + if (!is_identity_fixup(texture_gl->t.resource.format->color_fixup)) FIXME("Implement support for sign or swizzle fixups.\n"); shader = arbfp_gen_plain_shader(gl_info, &type); break; @@ -7648,7 +7648,7 @@ err_out: }
if (fixup == COMPLEX_FIXUP_P8) - upload_palette(blitter, texture, context); + upload_palette(blitter, &texture_gl->t, context);
gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB); checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)"); @@ -7658,7 +7658,7 @@ err_out: checkGLcall("glProgramLocalParameter4fvARB"); if (type.use_color_key) { - wined3d_format_get_float_color_key(texture->resource.format, color_key, float_color_key); + wined3d_format_get_float_color_key(texture_gl->t.resource.format, color_key, float_color_key); GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARBFP_BLIT_PARAM_COLOR_KEY_LOW, &float_color_key[0].r)); GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, @@ -7775,6 +7775,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter) { + struct wined3d_texture_gl *src_texture_gl = wined3d_texture_gl(src_texture); struct wined3d_device *device = dst_texture->resource.device; struct wined3d_texture *staging_texture = NULL; struct wined3d_arbfp_blitter *arbfp_blitter; @@ -7850,7 +7851,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl * flip in the blitter, we don't actually need that flip anyway. So we * use the surface's texture as scratch texture, and flip the source * rectangle instead. */ - texture2d_load_fb_texture(src_texture, src_sub_resource_idx, FALSE, context); + texture2d_load_fb_texture(src_texture_gl, src_sub_resource_idx, FALSE, context);
s = *src_rect; src_level = src_sub_resource_idx % src_texture->level_count; @@ -7901,10 +7902,10 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl color_key = &alpha_test_key; }
- arbfp_blit_set(arbfp_blitter, context, src_texture, src_sub_resource_idx, color_key); + arbfp_blit_set(arbfp_blitter, context, src_texture_gl, src_sub_resource_idx, color_key);
/* Draw a textured quad */ - context_draw_textured_quad(context, wined3d_texture_gl(src_texture), + context_draw_textured_quad(context, src_texture_gl, src_sub_resource_idx, src_rect, dst_rect, filter);
/* Leave the opengl state valid for blitting */ diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index fbe3d941de8..3446c8df9e9 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -462,7 +462,7 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co return; }
- key->objects[idx].target = wined3d_texture_get_sub_resource_target(&texture_gl->t, sub_resource_idx); + key->objects[idx].target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx); key->objects[idx].level = sub_resource_idx % texture_gl->t.level_count; key->objects[idx].layer = sub_resource_idx / texture_gl->t.level_count;
@@ -5596,7 +5596,7 @@ void context_draw_shaded_quad(struct wined3d_context *context, struct wined3d_te } quad[4];
- texture2d_get_blt_info(&texture_gl->t, sub_resource_idx, src_rect, &info); + 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); @@ -5674,7 +5674,7 @@ void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_ struct wined3d_blt_info info; unsigned int level;
- texture2d_get_blt_info(&texture_gl->t, sub_resource_idx, src_rect, &info); + texture2d_get_blt_info(texture_gl, sub_resource_idx, src_rect, &info);
gl_info->gl_ops.gl.p_glEnable(info.bind_target); checkGLcall("glEnable(bind_target)"); diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 9114f0344ab..ffa4951c0ca 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1351,7 +1351,7 @@ static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data) if (InterlockedIncrement(&op->texture->resource.bind_count) == 1) op->texture->sampler = op->stage;
- if (!prev || op->texture->target != prev->target + if (!prev || wined3d_texture_gl(op->texture)->target != wined3d_texture_gl(prev)->target || (!is_same_fixup(new_format->color_fixup, old_format->color_fixup) && !(can_use_texture_swizzle(gl_info, new_format) && can_use_texture_swizzle(gl_info, old_format))) || (new_fmt_flags & WINED3DFMT_FLAG_SHADOW) != (old_fmt_flags & WINED3DFMT_FLAG_SHADOW)) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index fc9730f64b9..37d2aab20bc 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -13063,7 +13063,7 @@ static void glsl_blitter_upload_palette(struct wined3d_glsl_blitter *blitter,
/* Context activation is done by the caller. */ static struct glsl_blitter_program *glsl_blitter_get_program(struct wined3d_glsl_blitter *blitter, - struct wined3d_context *context, const struct wined3d_texture *texture) + struct wined3d_context *context, const struct wined3d_texture_gl *texture_gl) { const struct wined3d_gl_info *gl_info = context->gl_info; struct glsl_blitter_program *program; @@ -13071,8 +13071,8 @@ static struct glsl_blitter_program *glsl_blitter_get_program(struct wined3d_glsl struct wine_rb_entry *entry;
memset(&args, 0, sizeof(args)); - args.texture_type = texture->target; - args.fixup = texture->resource.format->color_fixup; + args.texture_type = texture_gl->target; + args.fixup = texture_gl->t.resource.format->color_fixup;
if ((entry = wine_rb_get(&blitter->programs, &args))) return WINE_RB_ENTRY_VALUE(entry, struct glsl_blitter_program, entry); @@ -13103,11 +13103,11 @@ static struct glsl_blitter_program *glsl_blitter_get_program(struct wined3d_glsl }
static BOOL glsl_blitter_supported(enum wined3d_blit_op blit_op, const struct wined3d_context *context, - const struct wined3d_texture *src_texture, DWORD src_location, - const struct wined3d_texture *dst_texture, DWORD dst_location) + const struct wined3d_texture_gl *src_texture, DWORD src_location, + const struct wined3d_texture_gl *dst_texture, DWORD dst_location) { - const struct wined3d_resource *src_resource = &src_texture->resource; - const struct wined3d_resource *dst_resource = &dst_texture->resource; + const struct wined3d_resource *src_resource = &src_texture->t.resource; + const struct wined3d_resource *dst_resource = &dst_texture->t.resource; const struct wined3d_format *src_format = src_resource->format; const struct wined3d_format *dst_format = dst_resource->format; BOOL decompress; @@ -13166,6 +13166,8 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter) { + struct wined3d_texture_gl *src_texture_gl = wined3d_texture_gl(src_texture); + struct wined3d_texture_gl *dst_texture_gl = wined3d_texture_gl(dst_texture); struct wined3d_device *device = dst_texture->resource.device; const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_texture *staging_texture = NULL; @@ -13182,7 +13184,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli wine_dbgstr_rect(src_rect), dst_texture, dst_sub_resource_idx, wined3d_debug_location(dst_location), wine_dbgstr_rect(dst_rect), colour_key, debug_d3dtexturefiltertype(filter));
- if (!glsl_blitter_supported(op, context, src_texture, src_location, dst_texture, dst_location)) + if (!glsl_blitter_supported(op, context, src_texture_gl, src_location, dst_texture_gl, dst_location)) { if (!(next = blitter->next)) { @@ -13242,7 +13244,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli * flip in the blitter, we don't actually need that flip anyway. So we * use the surface's texture as scratch texture, and flip the source * rectangle instead. */ - texture2d_load_fb_texture(src_texture, src_sub_resource_idx, FALSE, context); + texture2d_load_fb_texture(src_texture_gl, src_sub_resource_idx, FALSE, context);
s = *src_rect; src_level = src_sub_resource_idx % src_texture->level_count; @@ -13285,7 +13287,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli context_invalidate_state(context, STATE_FRAMEBUFFER); }
- if (!(program = glsl_blitter_get_program(glsl_blitter, context, src_texture))) + if (!(program = glsl_blitter_get_program(glsl_blitter, context, src_texture_gl))) { ERR("Failed to get blitter program.\n"); return dst_location; @@ -13310,8 +13312,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli default: break; } - context_draw_shaded_quad(context, wined3d_texture_gl(src_texture), - src_sub_resource_idx, src_rect, dst_rect, filter); + context_draw_shaded_quad(context, src_texture_gl, src_sub_resource_idx, src_rect, dst_rect, filter); GL_EXTCALL(glUseProgram(0));
if (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture)) diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index 20db62739b5..e05df20bfda 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD stage, struct wined3d_context *context) { const struct wined3d_gl_info *gl_info = context->gl_info; + struct wined3d_texture *texture; BOOL bumpmap = FALSE;
if (stage > 0 @@ -47,9 +48,9 @@ static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD st context->texShaderBumpMap &= ~(1u << stage); }
- if (state->textures[stage]) + if ((texture = state->textures[stage])) { - switch (state->textures[stage]->target) + switch (wined3d_texture_gl(texture)->target) { case GL_TEXTURE_2D: gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, @@ -70,7 +71,7 @@ static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD st checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB)"); break; default: - FIXME("Unhandled target %#x.\n", state->textures[stage]->target); + FIXME("Unhandled target %#x.\n", wined3d_texture_gl(texture)->target); break; } } diff --git a/dlls/wined3d/sampler.c b/dlls/wined3d/sampler.c index 458a330774f..6e45f0e4b4e 100644 --- a/dlls/wined3d/sampler.c +++ b/dlls/wined3d/sampler.c @@ -175,7 +175,7 @@ static void texture_gl_apply_base_level(struct wined3d_texture_gl *texture_gl, * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest * mipmap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL * corresponds to GL_TEXTURE_BASE_LEVEL. */ - gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->t.target, GL_TEXTURE_BASE_LEVEL, base_level); + gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level); gl_tex->base_level = base_level; } } diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index ce45298b539..e11a37cf078 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3847,7 +3847,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 { const struct wined3d_d3d_info *d3d_info = context->d3d_info; const struct wined3d_gl_info *gl_info = context->gl_info; - const struct wined3d_texture *texture; + struct wined3d_texture *texture; unsigned int i;
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */ @@ -3922,18 +3922,16 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 { for (i = 0; i < shader->limits->sampler; ++i) { - const struct wined3d_texture *texture = state->textures[i]; - if (!shader->reg_maps.resource_info[i].type) continue;
/* Treat unbound textures as 2D. The dummy texture will provide * the proper sample value. The tex_types bitmap defaults to * 2D because of the memset. */ - if (!texture) + if (!(texture = state->textures[i])) continue;
- switch (texture->target) + switch (wined3d_texture_gl(texture)->target) { /* RECT textures are distinguished from 2D textures via np2_fixup */ default: diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 7f3961b7465..42c109da57b 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3213,12 +3213,13 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st
if (state->render_states[WINED3D_RS_COLORKEYENABLE] && !stage && state->textures[0]) { - struct wined3d_texture *texture = state->textures[0]; - GLenum texture_dimensions = texture->target; + struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(state->textures[0]); + GLenum texture_dimensions = texture_gl->target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB) { - if (texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT && !texture->resource.format->alpha_size) + if (texture_gl->t.async.color_key_flags & WINED3D_CKEY_SRC_BLT + && !texture_gl->t.resource.format->alpha_size) { /* Color keying needs to pass alpha values from the texture through to have the alpha test work * properly. On the other hand applications can still use texture combiners apparently. This code @@ -3516,7 +3517,7 @@ static void sampler_texmatrix(struct wined3d_context *context, const struct wine } }
-static enum wined3d_texture_address wined3d_texture_address_mode(const struct wined3d_texture *texture, +static enum wined3d_texture_address wined3d_texture_gl_address_mode(const struct wined3d_texture_gl *texture_gl, enum wined3d_texture_address t) { if (t < WINED3D_TADDRESS_WRAP || t > WINED3D_TADDRESS_MIRROR_ONCE) @@ -3526,7 +3527,7 @@ static enum wined3d_texture_address wined3d_texture_address_mode(const struct wi }
/* Cubemaps are always set to clamp, regardless of the sampler state. */ - if (texture->target == GL_TEXTURE_CUBE_MAP_ARB || ((texture->flags & WINED3D_TEXTURE_COND_NP2) + if (texture_gl->target == GL_TEXTURE_CUBE_MAP_ARB || ((texture_gl->t.flags & WINED3D_TEXTURE_COND_NP2) && t == WINED3D_TADDRESS_WRAP)) return WINED3D_TADDRESS_CLAMP;
@@ -3534,7 +3535,8 @@ static enum wined3d_texture_address wined3d_texture_address_mode(const struct wi }
static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc *desc, - const struct wined3d_context *context, const DWORD *sampler_states, const struct wined3d_texture *texture) + const struct wined3d_context *context, const DWORD *sampler_states, + const struct wined3d_texture_gl *texture_gl) { union { @@ -3542,9 +3544,9 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc DWORD d; } lod_bias;
- desc->address_u = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_U]); - desc->address_v = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_V]); - desc->address_w = wined3d_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_W]); + desc->address_u = wined3d_texture_gl_address_mode(texture_gl, sampler_states[WINED3D_SAMP_ADDRESS_U]); + desc->address_v = wined3d_texture_gl_address_mode(texture_gl, sampler_states[WINED3D_SAMP_ADDRESS_V]); + desc->address_w = wined3d_texture_gl_address_mode(texture_gl, sampler_states[WINED3D_SAMP_ADDRESS_W]); wined3d_color_from_d3dcolor((struct wined3d_color *)desc->border_color, sampler_states[WINED3D_SAMP_BORDER_COLOR]); if (sampler_states[WINED3D_SAMP_MAG_FILTER] > WINED3D_TEXF_ANISOTROPIC) @@ -3568,20 +3570,20 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc if ((sampler_states[WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_ANISOTROPIC && sampler_states[WINED3D_SAMP_MIN_FILTER] != WINED3D_TEXF_ANISOTROPIC && sampler_states[WINED3D_SAMP_MIP_FILTER] != WINED3D_TEXF_ANISOTROPIC) - || (texture->flags & WINED3D_TEXTURE_COND_NP2)) + || (texture_gl->t.flags & WINED3D_TEXTURE_COND_NP2)) desc->max_anisotropy = 1; - desc->compare = texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW; + desc->compare = texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_SHADOW; desc->comparison_func = WINED3D_CMP_LESSEQUAL; desc->srgb_decode = sampler_states[WINED3D_SAMP_SRGB_TEXTURE];
- if (!(texture->resource.format_flags & WINED3DFMT_FLAG_FILTERING)) + if (!(texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_FILTERING)) { desc->mag_filter = WINED3D_TEXF_POINT; desc->min_filter = WINED3D_TEXF_POINT; desc->mip_filter = WINED3D_TEXF_NONE; }
- if (texture->flags & WINED3D_TEXTURE_COND_NP2) + if (texture_gl->t.flags & WINED3D_TEXTURE_COND_NP2) { desc->mip_filter = WINED3D_TEXF_NONE; if (context->gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]) @@ -3620,7 +3622,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state struct wined3d_sampler *sampler; struct wine_rb_entry *entry;
- wined3d_sampler_desc_from_sampler_states(&desc, context, sampler_states, &texture_gl->t); + wined3d_sampler_desc_from_sampler_states(&desc, context, sampler_states, texture_gl);
wined3d_texture_gl_bind(texture_gl, context, srgb);
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 02cd2c376c1..21375dd026f 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -137,13 +137,13 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct checkGLcall("glBlitFramebuffer()"); }
-static BOOL is_multisample_location(const struct wined3d_texture *texture, DWORD location) +static BOOL is_multisample_location(const struct wined3d_texture_gl *texture_gl, DWORD location) { if (location == WINED3D_LOCATION_RB_MULTISAMPLE) return TRUE; if (location != WINED3D_LOCATION_TEXTURE_RGB && location != WINED3D_LOCATION_TEXTURE_SRGB) return FALSE; - return texture->target == GL_TEXTURE_2D_MULTISAMPLE || texture->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY; + return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY; }
/* Blit between surface locations. Onscreen on different swapchains is not supported. @@ -183,7 +183,7 @@ static void texture2d_blt_fbo(const struct wined3d_device *device, struct wined3 }
/* Resolve the source surface first if needed. */ - if (is_multisample_location(src_texture, src_location) + if (is_multisample_location(wined3d_texture_gl(src_texture), src_location) && (src_texture->resource.format->id != dst_texture->resource.format->id || abs(src_rect->bottom - src_rect->top) != abs(dst_rect->bottom - dst_rect->top) || abs(src_rect->right - src_rect->left) != abs(dst_rect->right - dst_rect->left))) @@ -835,41 +835,44 @@ error: * * Context activation is done by the caller. This function may temporarily * switch to a different context and restore the original one before return. */ -void texture2d_load_fb_texture(struct wined3d_texture *texture, +void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, BOOL srgb, struct wined3d_context *context) { - struct wined3d_device *device = texture->resource.device; struct wined3d_texture *restore_texture; const struct wined3d_gl_info *gl_info; + struct wined3d_resource *resource; unsigned int restore_idx, level; + struct wined3d_device *device; GLenum target;
+ resource = &texture_gl->t.resource; + device = resource->device; restore_texture = context->current_rt.texture; restore_idx = context->current_rt.sub_resource_idx; - if (restore_texture != texture || restore_idx != sub_resource_idx) - context = context_acquire(device, texture, sub_resource_idx); + if (restore_texture != &texture_gl->t || restore_idx != sub_resource_idx) + context = context_acquire(device, &texture_gl->t, sub_resource_idx); else restore_texture = NULL;
gl_info = context->gl_info; device_invalidate_state(device, STATE_FRAMEBUFFER);
- wined3d_texture_prepare_texture(texture, context, srgb); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, srgb); + wined3d_texture_prepare_texture(&texture_gl->t, context, srgb); + wined3d_texture_gl_bind_and_dirtify(texture_gl, context, srgb);
- TRACE("Reading back offscreen render target %p, %u.\n", texture, sub_resource_idx); + TRACE("Reading back offscreen render target %p, %u.\n", texture_gl, sub_resource_idx);
- if (wined3d_resource_is_offscreen(&texture->resource)) + if (wined3d_resource_is_offscreen(resource)) gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context)); else - gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(texture)); + gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(&texture_gl->t)); checkGLcall("glReadBuffer");
- level = sub_resource_idx % texture->level_count; - target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + level = sub_resource_idx % texture_gl->t.level_count; + target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx); gl_info->gl_ops.gl.p_glCopyTexSubImage2D(target, level, 0, 0, 0, 0, - wined3d_texture_get_level_width(texture, level), - wined3d_texture_get_level_height(texture, level)); + wined3d_texture_get_level_width(&texture_gl->t, level), + wined3d_texture_get_level_height(&texture_gl->t, level)); checkGLcall("glCopyTexSubImage2D");
if (restore_texture) @@ -907,7 +910,7 @@ static void fb_copy_to_texture_direct(struct wined3d_texture_gl *dst_texture, un wined3d_texture_load(&dst_texture->t, context, FALSE);
/* Bind the target texture */ - context_bind_texture(context, dst_texture->t.target, dst_texture->texture_rgb.name); + context_bind_texture(context, dst_texture->target, dst_texture->texture_rgb.name); if (wined3d_resource_is_offscreen(&src_texture->t.resource)) { TRACE("Reading from an offscreen target\n"); @@ -940,7 +943,7 @@ static void fb_copy_to_texture_direct(struct wined3d_texture_gl *dst_texture, un dst_level = dst_sub_resource_idx % dst_texture->t.level_count;
src_height = wined3d_texture_get_level_height(&src_texture->t, src_level); - dst_target = wined3d_texture_get_sub_resource_target(&dst_texture->t, dst_sub_resource_idx); + dst_target = wined3d_texture_gl_get_sub_resource_target(dst_texture, dst_sub_resource_idx); if (upsidedown && !((xrel - 1.0f < -eps) || (xrel - 1.0f > eps)) && !((yrel - 1.0f < -eps) || (yrel - 1.0f > eps))) @@ -1015,8 +1018,8 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_texture_gl *dst_texture,
TRACE("Using hwstretch blit\n");
- src_target = wined3d_texture_get_sub_resource_target(&src_texture->t, src_sub_resource_idx); - dst_target = wined3d_texture_get_sub_resource_target(&dst_texture->t, dst_sub_resource_idx); + src_target = wined3d_texture_gl_get_sub_resource_target(src_texture, src_sub_resource_idx); + dst_target = wined3d_texture_gl_get_sub_resource_target(dst_texture, dst_sub_resource_idx);
/* 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); @@ -1423,7 +1426,7 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res wined3d_texture_prepare_location(texture, sub_resource_idx, context, dst_location);
/* We cannot download data from multisample textures directly. */ - if (is_multisample_location(texture, WINED3D_LOCATION_TEXTURE_RGB)) + if (is_multisample_location(wined3d_texture_gl(texture), WINED3D_LOCATION_TEXTURE_RGB)) { wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_RB_RESOLVED); texture2d_read_from_framebuffer(texture, sub_resource_idx, context, @@ -1528,7 +1531,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re && wined3d_resource_is_offscreen(&texture->resource) && (sub_resource->locations & WINED3D_LOCATION_DRAWABLE)) { - texture2d_load_fb_texture(texture, sub_resource_idx, srgb, context); + texture2d_load_fb_texture(wined3d_texture_gl(texture), sub_resource_idx, srgb, context);
return TRUE; } @@ -1840,6 +1843,8 @@ static DWORD raw_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter) { + struct wined3d_texture_gl *src_texture_gl = wined3d_texture_gl(src_texture); + struct wined3d_texture_gl *dst_texture_gl = wined3d_texture_gl(dst_texture); const struct wined3d_gl_info *gl_info = context->gl_info; unsigned int src_level, src_layer, dst_level, dst_layer; struct wined3d_blitter *next; @@ -1879,7 +1884,7 @@ static DWORD raw_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB; if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, location)) ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(location)); - src_name = wined3d_texture_gl_get_texture_name(wined3d_texture_gl(src_texture), + src_name = wined3d_texture_gl_get_texture_name(src_texture_gl, context, location == WINED3D_LOCATION_TEXTURE_SRGB);
location = dst_location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB); @@ -1896,11 +1901,11 @@ static DWORD raw_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, location)) ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(location)); } - dst_name = wined3d_texture_gl_get_texture_name(wined3d_texture_gl(dst_texture), + dst_name = wined3d_texture_gl_get_texture_name(dst_texture_gl, context, location == WINED3D_LOCATION_TEXTURE_SRGB);
- GL_EXTCALL(glCopyImageSubData(src_name, src_texture->target, src_level, - src_rect->left, src_rect->top, src_layer, dst_name, dst_texture->target, dst_level, + GL_EXTCALL(glCopyImageSubData(src_name, src_texture_gl->target, src_level, + src_rect->left, src_rect->top, src_layer, dst_name, dst_texture_gl->target, dst_level, dst_rect->left, dst_rect->top, dst_layer, src_rect->right - src_rect->left, src_rect->bottom - src_rect->top, 1)); checkGLcall("copy image data"); @@ -2098,6 +2103,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter) { + struct wined3d_texture_gl *src_texture_gl = wined3d_texture_gl(src_texture); const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_resource *src_resource, *dst_resource; struct wined3d_texture *staging_texture = NULL; @@ -2198,7 +2204,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit context_invalidate_state(context, STATE_FRAMEBUFFER); }
- gl_info->gl_ops.gl.p_glEnable(src_texture->target); + gl_info->gl_ops.gl.p_glEnable(src_texture_gl->target); checkGLcall("glEnable(target)");
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST || color_key) @@ -2220,7 +2226,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit checkGLcall("glAlphaFunc"); }
- context_draw_textured_quad(context, wined3d_texture_gl(src_texture), + context_draw_textured_quad(context, src_texture_gl, src_sub_resource_idx, src_rect, dst_rect, filter);
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST || color_key) @@ -3276,7 +3282,7 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ TRACE("Not doing download because of format conversion.\n"); else if (src_texture->resource.format->conv_byte_count) TRACE("Not doing download because the source format needs conversion.\n"); - else if (is_multisample_location(src_texture, WINED3D_LOCATION_TEXTURE_RGB)) + else if (is_multisample_location(wined3d_texture_gl(src_texture), WINED3D_LOCATION_TEXTURE_RGB)) TRACE("Not doing download because of multisample source.\n"); else if (!texture2d_is_full_rect(src_texture, src_sub_resource_idx % src_texture->level_count, &src_rect)) TRACE("Not doing download because of partial download (src).\n"); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index f1a2498f777..9b9e825f4fb 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -153,7 +153,7 @@ static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct wined f->b = ((r->bottom * 2.0f) / h) - 1.0f; }
-void texture2d_get_blt_info(const struct wined3d_texture *texture, +void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const RECT *rect, struct wined3d_blt_info *info) { struct wined3d_vec3 *coords = info->texcoords; @@ -162,10 +162,10 @@ void texture2d_get_blt_info(const struct wined3d_texture *texture, GLenum target; GLsizei w, h;
- level = sub_resource_idx % texture->level_count; - w = wined3d_texture_get_level_pow2_width(texture, level); - h = wined3d_texture_get_level_pow2_height(texture, level); - target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + level = sub_resource_idx % texture_gl->t.level_count; + w = wined3d_texture_get_level_pow2_width(&texture_gl->t, level); + h = wined3d_texture_get_level_pow2_height(&texture_gl->t, level); + target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx);
switch (target) { @@ -564,7 +564,7 @@ static unsigned int wined3d_texture_get_gl_sample_count(const struct wined3d_tex
/* Context activation is done by the caller. */ /* The caller is responsible for binding the correct texture. */ -static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *texture, +static void wined3d_texture_gl_allocate_mutable_storage(struct wined3d_texture_gl *texture_gl, GLenum gl_internal_format, const struct wined3d_format_gl *format, const struct wined3d_gl_info *gl_info) { @@ -572,34 +572,34 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture * GLsizei width, height, depth; GLenum target;
- level_count = texture->level_count; - if (texture->target == GL_TEXTURE_1D_ARRAY || texture->target == GL_TEXTURE_2D_ARRAY) + level_count = texture_gl->t.level_count; + if (texture_gl->target == GL_TEXTURE_1D_ARRAY || texture_gl->target == GL_TEXTURE_2D_ARRAY) layer_count = 1; else - layer_count = texture->layer_count; + layer_count = texture_gl->t.layer_count;
for (layer = 0; layer < layer_count; ++layer) { - target = wined3d_texture_get_sub_resource_target(texture, layer * level_count); + target = wined3d_texture_gl_get_sub_resource_target(texture_gl, layer * level_count);
for (level = 0; level < level_count; ++level) { - width = wined3d_texture_get_level_pow2_width(texture, level); - height = wined3d_texture_get_level_pow2_height(texture, level); - if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE) + width = wined3d_texture_get_level_pow2_width(&texture_gl->t, level); + height = wined3d_texture_get_level_pow2_height(&texture_gl->t, level); + if (texture_gl->t.resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE) { height *= format->f.height_scale.numerator; height /= format->f.height_scale.denominator; }
- TRACE("texture %p, layer %u, level %u, target %#x, width %u, height %u.\n", - texture, layer, level, target, width, height); + TRACE("texture_gl %p, layer %u, level %u, target %#x, width %u, height %u.\n", + texture_gl, layer, level, target, width, height);
if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) { - depth = wined3d_texture_get_level_depth(texture, level); + depth = wined3d_texture_get_level_depth(&texture_gl->t, level); GL_EXTCALL(glTexImage3D(target, level, gl_internal_format, width, height, - target == GL_TEXTURE_2D_ARRAY ? texture->layer_count : depth, 0, + target == GL_TEXTURE_2D_ARRAY ? texture_gl->t.layer_count : depth, 0, format->format, format->type, NULL)); checkGLcall("glTexImage3D"); } @@ -611,7 +611,7 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture * else { gl_info->gl_ops.gl.p_glTexImage2D(target, level, gl_internal_format, width, - target == GL_TEXTURE_1D_ARRAY ? texture->layer_count : height, 0, + target == GL_TEXTURE_1D_ARRAY ? texture_gl->t.layer_count : height, 0, format->format, format->type, NULL); checkGLcall("glTexImage2D"); } @@ -621,42 +621,42 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *
/* Context activation is done by the caller. */ /* The caller is responsible for binding the correct texture. */ -static void wined3d_texture_allocate_gl_immutable_storage(struct wined3d_texture *texture, +static void wined3d_texture_gl_allocate_immutable_storage(struct wined3d_texture_gl *texture_gl, GLenum gl_internal_format, const struct wined3d_gl_info *gl_info) { - unsigned int samples = wined3d_texture_get_gl_sample_count(texture); - GLsizei height = wined3d_texture_get_level_pow2_height(texture, 0); - GLsizei width = wined3d_texture_get_level_pow2_width(texture, 0); - GLboolean standard_pattern = texture->resource.multisample_type != WINED3D_MULTISAMPLE_NON_MASKABLE - && texture->resource.multisample_quality == WINED3D_STANDARD_MULTISAMPLE_PATTERN; + unsigned int samples = wined3d_texture_get_gl_sample_count(&texture_gl->t); + GLsizei height = wined3d_texture_get_level_pow2_height(&texture_gl->t, 0); + GLsizei width = wined3d_texture_get_level_pow2_width(&texture_gl->t, 0); + GLboolean standard_pattern = texture_gl->t.resource.multisample_type != WINED3D_MULTISAMPLE_NON_MASKABLE + && texture_gl->t.resource.multisample_quality == WINED3D_STANDARD_MULTISAMPLE_PATTERN;
- switch (texture->target) + switch (texture_gl->target) { case GL_TEXTURE_3D: - GL_EXTCALL(glTexStorage3D(texture->target, texture->level_count, - gl_internal_format, width, height, wined3d_texture_get_level_depth(texture, 0))); + GL_EXTCALL(glTexStorage3D(texture_gl->target, texture_gl->t.level_count, + gl_internal_format, width, height, wined3d_texture_get_level_depth(&texture_gl->t, 0))); break; case GL_TEXTURE_2D_ARRAY: - GL_EXTCALL(glTexStorage3D(texture->target, texture->level_count, - gl_internal_format, width, height, texture->layer_count)); + GL_EXTCALL(glTexStorage3D(texture_gl->target, texture_gl->t.level_count, + gl_internal_format, width, height, texture_gl->t.layer_count)); break; case GL_TEXTURE_2D_MULTISAMPLE: - GL_EXTCALL(glTexStorage2DMultisample(texture->target, samples, + GL_EXTCALL(glTexStorage2DMultisample(texture_gl->target, samples, gl_internal_format, width, height, standard_pattern)); break; case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: - GL_EXTCALL(glTexStorage3DMultisample(texture->target, samples, - gl_internal_format, width, height, texture->layer_count, standard_pattern)); + GL_EXTCALL(glTexStorage3DMultisample(texture_gl->target, samples, + gl_internal_format, width, height, texture_gl->t.layer_count, standard_pattern)); break; case GL_TEXTURE_1D_ARRAY: - GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count, - gl_internal_format, width, texture->layer_count)); + GL_EXTCALL(glTexStorage2D(texture_gl->target, texture_gl->t.level_count, + gl_internal_format, width, texture_gl->t.layer_count)); break; case GL_TEXTURE_1D: - GL_EXTCALL(glTexStorage1D(texture->target, texture->level_count, gl_internal_format, width)); + GL_EXTCALL(glTexStorage1D(texture_gl->target, texture_gl->t.level_count, gl_internal_format, width)); break; default: - GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count, + GL_EXTCALL(glTexStorage2D(texture_gl->target, texture_gl->t.level_count, gl_internal_format, width, height)); break; } @@ -978,7 +978,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, texture_gl->t.flags &= ~WINED3D_TEXTURE_IS_SRGB;
gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, srgb); - target = texture_gl->t.target; + target = texture_gl->target;
if (gl_tex->name) { @@ -1112,7 +1112,7 @@ void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) { const struct wined3d_gl_info *gl_info = context->gl_info; - GLenum target = texture_gl->t.target; + GLenum target = texture_gl->target; struct gl_texture *gl_tex; DWORD state;
@@ -1645,9 +1645,9 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT sub_resource->locations = WINED3D_LOCATION_DISCARDED;
if (multisample_type && gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) - texture->target = GL_TEXTURE_2D_MULTISAMPLE; + wined3d_texture_gl(texture)->target = GL_TEXTURE_2D_MULTISAMPLE; else - texture->target = GL_TEXTURE_2D; + wined3d_texture_gl(texture)->target = GL_TEXTURE_2D;
if (((width & (width - 1)) || (height & (height - 1))) && !d3d_info->texture_npot && !d3d_info->texture_npot_conditional) @@ -1794,9 +1794,9 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win TRACE("internal %#x, format %#x, type %#x.\n", internal, format_gl->format, format_gl->type);
if (wined3d_texture_use_immutable_storage(texture, gl_info)) - wined3d_texture_allocate_gl_immutable_storage(texture, internal, gl_info); + wined3d_texture_gl_allocate_immutable_storage(wined3d_texture_gl(texture), internal, gl_info); else - wined3d_texture_allocate_gl_mutable_storage(texture, internal, format_gl, gl_info); + wined3d_texture_gl_allocate_mutable_storage(wined3d_texture_gl(texture), internal, format_gl, gl_info); texture->flags |= alloc_flag; }
@@ -1959,7 +1959,7 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s update_h /= format->height_scale.denominator; }
- target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + target = wined3d_texture_gl_get_sub_resource_target(wined3d_texture_gl(texture), sub_resource_idx); level = sub_resource_idx % texture->level_count;
switch (target) @@ -2183,7 +2183,7 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in }
sub_resource = &texture->sub_resources[sub_resource_idx]; - target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + target = wined3d_texture_gl_get_sub_resource_target(wined3d_texture_gl(texture), sub_resource_idx); level = sub_resource_idx % texture->level_count;
if (target == GL_TEXTURE_2D_ARRAY) @@ -2398,7 +2398,7 @@ void wined3d_texture_download_data(struct wined3d_texture *texture, unsigned int GLenum target;
format_gl = wined3d_format_gl(texture->resource.format); - target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + target = wined3d_texture_gl_get_sub_resource_target(wined3d_texture_gl(texture), sub_resource_idx); level = sub_resource_idx % texture->level_count;
if (texture->resource.type == WINED3D_RTYPE_TEXTURE_2D @@ -3052,53 +3052,12 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc texture->flags |= WINED3D_TEXTURE_GENERATE_MIPMAPS; }
- switch (desc->resource_type) - { - case WINED3D_RTYPE_TEXTURE_1D: - if (layer_count > 1) - texture->target = GL_TEXTURE_1D_ARRAY; - else - texture->target = GL_TEXTURE_1D; - break; - - case WINED3D_RTYPE_TEXTURE_2D: - if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) - { - texture->target = GL_TEXTURE_CUBE_MAP_ARB; - } - else if (desc->multisample_type && gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) - { - if (layer_count > 1) - texture->target = GL_TEXTURE_2D_MULTISAMPLE_ARRAY; - else - texture->target = GL_TEXTURE_2D_MULTISAMPLE; - } - else - { - if (layer_count > 1) - texture->target = GL_TEXTURE_2D_ARRAY; - else - texture->target = GL_TEXTURE_2D; - } - break; - - case WINED3D_RTYPE_TEXTURE_3D: - texture->target = GL_TEXTURE_3D; - break; - - default: - ERR("Invalid resource type %s.\n", debug_d3dresourcetype(desc->resource_type)); - wined3d_texture_cleanup_sync(texture); - return WINED3DERR_INVALIDCALL; - } - /* Precalculated scaling for 'faked' non power of two texture coords. */ if (texture->resource.gl_type == WINED3D_GL_RES_TYPE_TEX_RECT) { texture->pow2_matrix[0] = (float)desc->width; texture->pow2_matrix[5] = (float)desc->height; texture->flags &= ~(WINED3D_TEXTURE_POW2_MAT_IDENT | WINED3D_TEXTURE_NORMALIZED_COORDS); - texture->target = GL_TEXTURE_RECTANGLE_ARB; } else if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED) { @@ -3594,7 +3553,9 @@ static HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, st const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, DWORD flags, void *parent, const struct wined3d_parent_ops *parent_ops, void *sub_resources) { + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_texture_ops *texture_ops; + HRESULT hr;
TRACE("texture_gl %p, device %p, desc %p, layer_count %u, level_count %u, " "flags %#x, parent %p, parent_ops %p, sub_resources %p.\n", @@ -3605,13 +3566,39 @@ static HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, st { case WINED3D_RTYPE_TEXTURE_1D: texture_ops = &texture1d_ops; + if (layer_count > 1) + texture_gl->target = GL_TEXTURE_1D_ARRAY; + else + texture_gl->target = GL_TEXTURE_1D; break; + case WINED3D_RTYPE_TEXTURE_2D: texture_ops = &texture2d_ops; + if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) + { + texture_gl->target = GL_TEXTURE_CUBE_MAP_ARB; + } + else if (desc->multisample_type && gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) + { + if (layer_count > 1) + texture_gl->target = GL_TEXTURE_2D_MULTISAMPLE_ARRAY; + else + texture_gl->target = GL_TEXTURE_2D_MULTISAMPLE; + } + else + { + if (layer_count > 1) + texture_gl->target = GL_TEXTURE_2D_ARRAY; + else + texture_gl->target = GL_TEXTURE_2D; + } break; + case WINED3D_RTYPE_TEXTURE_3D: texture_ops = &texture3d_ops; + texture_gl->target = GL_TEXTURE_3D; break; + default: ERR("Invalid resource type %s.\n", debug_d3dresourcetype(desc->resource_type)); return WINED3DERR_INVALIDCALL; @@ -3619,8 +3606,14 @@ static HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, st
list_init(&texture_gl->renderbuffers);
- return wined3d_texture_init(&texture_gl->t, desc, layer_count, level_count, - flags, device, parent, parent_ops, sub_resources, texture_ops); + if (FAILED(hr = wined3d_texture_init(&texture_gl->t, desc, layer_count, level_count, + flags, device, parent, parent_ops, sub_resources, texture_ops))) + return hr; + + if (texture_gl->t.resource.gl_type == WINED3D_GL_RES_TYPE_TEX_RECT) + texture_gl->target = GL_TEXTURE_RECTANGLE_ARB; + + return WINED3D_OK; }
HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6e60c5ae3db..0bc4a37df45 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5767,7 +5767,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d
for (i = 0; i < d3d_info->limits.ffp_blend_stages; ++i) { - const struct wined3d_texture *texture; + struct wined3d_texture *texture;
settings->op[i].padding = 0; if (state->texture_states[i][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_DISABLE) @@ -5796,7 +5796,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d } else { - switch (texture->target) + switch (wined3d_texture_gl(texture)->target) { case GL_TEXTURE_1D: settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_1D; @@ -5857,7 +5857,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d GLenum texture_dimensions;
texture = state->textures[0]; - texture_dimensions = texture->target; + texture_dimensions = wined3d_texture_gl(texture)->target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB) { @@ -6063,11 +6063,11 @@ void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *des * not care for the colorop or correct gl texture unit (when using nvrc). * Requires the caller to activate the correct unit. */ /* Context activation is done by the caller (state handler). */ -void texture_activate_dimensions(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) +void texture_activate_dimensions(struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) { if (texture) { - switch (texture->target) + switch (wined3d_texture_gl(texture)->target) { case GL_TEXTURE_2D: gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 3b579a25f0f..004611eb2c7 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -33,7 +33,7 @@ static BOOL is_stencil_view_format(const struct wined3d_format *format) }
static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info, - const struct wined3d_view_desc *desc, const struct wined3d_texture *texture) + const struct wined3d_view_desc *desc, const struct wined3d_texture_gl *texture_gl) { static const struct { @@ -69,7 +69,7 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info,
for (i = 0; i < ARRAY_SIZE(view_types); ++i) { - if (view_types[i].texture_target != texture->target || view_types[i].view_flags != desc->flags) + if (view_types[i].texture_target != texture_gl->target || view_types[i].view_flags != desc->flags) continue; if (gl_info->supported[view_types[i].extension]) return view_types[i].view_target; @@ -77,8 +77,8 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info, FIXME("Extension %#x not supported.\n", view_types[i].extension); }
- FIXME("Unhandled view flags %#x for texture target %#x.\n", desc->flags, texture->target); - return texture->target; + FIXME("Unhandled view flags %#x for texture target %#x.\n", desc->flags, texture_gl->target); + return texture_gl->target; }
static const struct wined3d_format *validate_resource_view(const struct wined3d_view_desc *desc, @@ -564,7 +564,7 @@ static void wined3d_render_target_view_cs_init(void *object) return; }
- create_texture_view(&view->gl_view, texture_gl->t.target, desc, texture_gl, view->format); + create_texture_view(&view->gl_view, texture_gl->target, desc, texture_gl, view->format); } } } @@ -747,9 +747,9 @@ static void wined3d_shader_resource_view_cs_init(void *object)
resource_class = wined3d_format_gl(resource->format)->view_class; view_class = wined3d_format_gl(view_format)->view_class; - view_target = get_texture_view_target(gl_info, desc, &texture_gl->t); + view_target = get_texture_view_target(gl_info, desc, texture_gl);
- if (resource->format->id == view_format->id && texture_gl->t.target == view_target + if (resource->format->id == view_format->id && texture_gl->target == view_target && !desc->u.texture.level_idx && desc->u.texture.level_count == texture_gl->t.level_count && !desc->u.texture.layer_idx && desc->u.texture.layer_count == texture_gl->t.layer_count && !is_stencil_view_format(view_format)) @@ -898,8 +898,8 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view * else { wined3d_texture_gl_bind_and_dirtify(texture_gl, context, srgb); - gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->t.target, GL_TEXTURE_BASE_LEVEL, base_level); - gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->t.target, GL_TEXTURE_MAX_LEVEL, max_level); + gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level); + gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, max_level); }
if (gl_info->supported[ARB_SAMPLER_OBJECTS]) @@ -907,12 +907,12 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view * gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, srgb); if (context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL) { - gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->t.target, GL_TEXTURE_SRGB_DECODE_EXT, - GL_SKIP_DECODE_EXT); + gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, + GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); gl_tex->sampler_desc.srgb_decode = FALSE; }
- gl_info->fbo_ops.glGenerateMipmap(texture_gl->t.target); + gl_info->fbo_ops.glGenerateMipmap(texture_gl->target); checkGLcall("glGenerateMipMap()");
for (i = 0; i < layer_count; ++i) @@ -927,7 +927,7 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view * if (!view->gl_view.name) { gl_tex->base_level = base_level; - gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->t.target, + gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1); }
@@ -1141,7 +1141,7 @@ static void wined3d_unordered_access_view_cs_init(void *object)
if (desc->u.texture.layer_idx || desc->u.texture.layer_count != depth_or_layer_count) { - create_texture_view(&view->gl_view, get_texture_view_target(gl_info, desc, &texture_gl->t), + create_texture_view(&view->gl_view, get_texture_view_target(gl_info, desc, texture_gl), desc, texture_gl, view->format); } } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 861c6475420..84bf14d51f4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3217,7 +3217,6 @@ struct wined3d_texture UINT lod; DWORD sampler; DWORD flags; - GLenum target; DWORD update_map_binding;
void *user_memory; @@ -3273,23 +3272,6 @@ static inline struct wined3d_texture *texture_from_resource(struct wined3d_resou return CONTAINING_RECORD(resource, struct wined3d_texture, resource); }
-static inline GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, - unsigned int sub_resource_idx) -{ - static const GLenum cube_targets[] = - { - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, - }; - - return texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP - ? cube_targets[sub_resource_idx / texture->level_count] : texture->target; -} - static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level) { @@ -3333,11 +3315,11 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ const struct wined3d_box *dst_box, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags, const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN; -void texture2d_get_blt_info(const struct wined3d_texture *texture, unsigned int sub_resource_idx, +void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const RECT *rect, struct wined3d_blt_info *info) DECLSPEC_HIDDEN; BOOL texture2d_load_drawable(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context) DECLSPEC_HIDDEN; -void texture2d_load_fb_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx, +void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN; BOOL texture2d_load_renderbuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN; @@ -3395,6 +3377,8 @@ struct wined3d_texture_gl
struct gl_texture texture_rgb, texture_srgb;
+ GLenum target; + GLuint rb_multisample; GLuint rb_resolved;
@@ -3413,6 +3397,23 @@ static inline struct gl_texture *wined3d_texture_gl_get_gl_texture(struct wined3 return srgb ? &texture_gl->texture_srgb : &texture_gl->texture_rgb; }
+static inline GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl, + unsigned int sub_resource_idx) +{ + static const GLenum cube_targets[] = + { + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, + }; + + return texture_gl->t.resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP + ? cube_targets[sub_resource_idx / texture_gl->t.level_count] : texture_gl->target; +} + void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl, const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) DECLSPEC_HIDDEN; void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, @@ -3986,7 +3987,7 @@ BOOL is_invalid_op(const struct wined3d_state *state, int stage, void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state, BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) DECLSPEC_HIDDEN; -void texture_activate_dimensions(const struct wined3d_texture *texture, +void texture_activate_dimensions(struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; void sampler_texdim(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43662
Your paranoid android.
=== debian9 (build log) ===
Global symbol "$Running" requires explicit package name (did you forget to declare "my $Running"?) at ../bin/build/WineTest.pl line 87.
=== debian9 (build log) ===
Global symbol "$Running" requires explicit package name (did you forget to declare "my $Running"?) at ../bin/build/WineTest.pl line 87.