From 9076612e2de0d52f2f526241283157b11eb989e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 22 Apr 2015 11:30:15 +0200 Subject: [PATCH] wined3d: Shadow format flags in the resource. --- dlls/wined3d/context.c | 7 +++--- dlls/wined3d/cs.c | 4 +++- dlls/wined3d/device.c | 4 ++-- dlls/wined3d/resource.c | 39 ++++++++++++++++-------------- dlls/wined3d/shader.c | 2 +- dlls/wined3d/state.c | 4 ++-- dlls/wined3d/surface.c | 43 +++++++++++++++++++++------------- dlls/wined3d/texture.c | 4 ++-- dlls/wined3d/volume.c | 11 +++++---- dlls/wined3d/wined3d_private.h | 1 + 10 files changed, 69 insertions(+), 50 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 1d7cf9ca9b9..0334d1c8a5e 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -128,7 +128,7 @@ static void context_attach_depth_stencil_fbo(struct wined3d_context *context, if (depth_stencil) { - DWORD format_flags = depth_stencil->resource.format->flags; + DWORD format_flags = depth_stencil->resource.format_flags; if (depth_stencil->current_renderbuffer) { @@ -3168,11 +3168,12 @@ static void context_setup_target(struct wined3d_context *context, struct wined3d { /* Disable blending when the alpha mask has changed and when a format doesn't support blending. */ if ((old->alpha_size && !new->alpha_size) || (!old->alpha_size && new->alpha_size) - || !(new->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) + || !(target->resource.format_flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE)); /* Update sRGB writing when switching between formats that do/do not support sRGB writing */ - if ((old->flags & WINED3DFMT_FLAG_SRGB_WRITE) != (new->flags & WINED3DFMT_FLAG_SRGB_WRITE)) + if ((context->current_rt->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE) + != (target->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE)) context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE)); } diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index d66850a531e..874129a0fee 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -649,13 +649,15 @@ static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data) { const struct wined3d_format *new_format = op->texture->resource.format; const struct wined3d_format *old_format = prev ? prev->resource.format : NULL; + unsigned int old_fmt_flags = prev ? prev->resource.format_flags : 0; + unsigned int new_fmt_flags = op->texture->resource.format_flags; if (InterlockedIncrement(&op->texture->resource.bind_count) == 1) op->texture->sampler = op->stage; if (!prev || op->texture->target != prev->target || !is_same_fixup(new_format->color_fixup, old_format->color_fixup) - || (new_format->flags & WINED3DFMT_FLAG_SHADOW) != (old_format->flags & WINED3DFMT_FLAG_SHADOW)) + || (new_fmt_flags & WINED3DFMT_FLAG_SHADOW) != (old_fmt_flags & WINED3DFMT_FLAG_SHADOW)) device_invalidate_state(cs->device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); if (!prev && op->stage < d3d_info->limits.ffp_blend_stages) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5f44a1a9889..4954d0001e2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1925,7 +1925,7 @@ static void resolve_depth_buffer(struct wined3d_state *state) struct wined3d_surface *depth_stencil, *surface; if (!texture || texture->resource.type != WINED3D_RTYPE_TEXTURE - || !(texture->resource.format->flags & WINED3DFMT_FLAG_DEPTH)) + || !(texture->resource.format_flags & WINED3DFMT_FLAG_DEPTH)) return; surface = surface_from_resource(texture->sub_resources[0]); if (!(depth_stencil = wined3d_rendertarget_view_get_surface(state->fb->depth_stencil))) @@ -3674,7 +3674,7 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device } texture = state->textures[i]; - if (!texture || texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING) continue; + if (!texture || texture->resource.format_flags & WINED3DFMT_FLAG_FILTERING) continue; if (state->sampler_states[i][WINED3D_SAMP_MAG_FILTER] != WINED3D_TEXF_POINT) { diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 205f074d386..efdb2a8701c 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -81,29 +81,12 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * const struct wined3d *d3d = device->wined3d; resource_check_usage(usage); - if (pool != WINED3D_POOL_SCRATCH && type != WINED3D_RTYPE_BUFFER) - { - if ((usage & WINED3DUSAGE_RENDERTARGET) && !(format->flags & WINED3DFMT_FLAG_RENDERTARGET)) - { - WARN("Format %s cannot be used for render targets.\n", debug_d3dformat(format->id)); - return WINED3DERR_INVALIDCALL; - } - if ((usage & WINED3DUSAGE_DEPTHSTENCIL) && !(format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))) - { - WARN("Format %s cannot be used for depth/stencil buffers.\n", debug_d3dformat(format->id)); - return WINED3DERR_INVALIDCALL; - } - if ((usage & WINED3DUSAGE_TEXTURE) && !(format->flags & WINED3DFMT_FLAG_TEXTURE)) - { - WARN("Format %s cannot be used for texturing.\n", debug_d3dformat(format->id)); - return WINED3DERR_INVALIDCALL; - } - } resource->ref = 1; resource->device = device; resource->type = type; resource->format = format; + resource->format_flags = format->flags; resource->multisample_type = multisample_type; resource->multisample_quality = multisample_quality; resource->usage = usage; @@ -121,6 +104,26 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * resource->resource_ops = resource_ops; resource->map_binding = WINED3D_LOCATION_SYSMEM; + if (pool != WINED3D_POOL_SCRATCH && type != WINED3D_RTYPE_BUFFER) + { + if ((usage & WINED3DUSAGE_RENDERTARGET) && !(resource->format_flags & WINED3DFMT_FLAG_RENDERTARGET)) + { + WARN("Format %s cannot be used for render targets.\n", debug_d3dformat(format->id)); + return WINED3DERR_INVALIDCALL; + } + if ((usage & WINED3DUSAGE_DEPTHSTENCIL) && + !(resource->format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))) + { + WARN("Format %s cannot be used for depth/stencil buffers.\n", debug_d3dformat(format->id)); + return WINED3DERR_INVALIDCALL; + } + if ((usage & WINED3DUSAGE_TEXTURE) && !(resource->format_flags & WINED3DFMT_FLAG_TEXTURE)) + { + WARN("Format %s cannot be used for texturing.\n", debug_d3dformat(format->id)); + return WINED3DERR_INVALIDCALL; + } + } + if (size) { if (!wined3d_resource_allocate_sysmem(resource)) diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 0bedf244634..d5a90c09256 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2459,7 +2459,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 } args->color_fixup[i] = texture->resource.format->color_fixup; - if (texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW) + if (texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW) args->shadow |= 1 << i; /* Flag samplers that need NP2 texcoord fixup. */ diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 7efbf3d2995..91f348565c7 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3632,11 +3632,11 @@ static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc && sampler_states[WINED3D_SAMP_MIP_FILTER] != WINED3D_TEXF_ANISOTROPIC) || (texture->flags & WINED3D_TEXTURE_COND_NP2)) desc->max_anisotropy = 1; - desc->compare = texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW; + desc->compare = texture->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->resource.format_flags & WINED3DFMT_FLAG_FILTERING)) { desc->mag_filter = WINED3D_TEXF_POINT; desc->min_filter = WINED3D_TEXF_POINT; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 77a0eaec063..e21b9ca21cf 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -359,6 +359,7 @@ static void get_color_masks(const struct wined3d_format *format, DWORD *masks) static HRESULT surface_create_dib_section(struct wined3d_surface *surface) { const struct wined3d_format *format = surface->resource.format; + unsigned int format_flags = surface->resource.format_flags; SYSTEM_INFO sysInfo; BITMAPINFO *b_info; int extraline = 0; @@ -366,7 +367,7 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface) TRACE("surface %p.\n", surface); - if (!(format->flags & WINED3DFMT_FLAG_GETDC)) + if (!(format_flags & WINED3DFMT_FLAG_GETDC)) { WARN("Cannot use GetDC on a %s surface.\n", debug_d3dformat(format->id)); return WINED3DERR_INVALIDCALL; @@ -664,7 +665,7 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface) if (pow2Width > surface->resource.width || pow2Height > surface->resource.height) { /* TODO: Add support for non power two compressed textures. */ - if (surface->resource.format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE)) + if (surface->resource.format_flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE)) { FIXME("(%p) Compressed or height scaled non-power-two textures are not supported w(%d) h(%d)\n", surface, surface->resource.width, surface->resource.height); @@ -751,7 +752,7 @@ static void surface_unmap(struct wined3d_surface *surface) if (surface->container->swapchain && surface->container->swapchain->front_buffer == surface->container) surface_load_location(surface, surface->container->resource.draw_binding); - else if (surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) + else if (surface->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) FIXME("Depth / stencil buffer locking is not implemented.\n"); } @@ -779,8 +780,8 @@ static void surface_depth_blt_fbo(const struct wined3d_device *device, TRACE("dst_surface %p, dst_location %s, dst_rect %s.\n", dst_surface, wined3d_debug_location(dst_location), wine_dbgstr_rect(dst_rect)); - src_mask = src_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); - dst_mask = dst_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); + src_mask = src_surface->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); + dst_mask = dst_surface->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); if (src_mask != dst_mask) { @@ -1276,7 +1277,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct surface_get_memory(surface, &data, dst_location); - if (format->flags & WINED3DFMT_FLAG_COMPRESSED) + if (surface->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED) { TRACE("(%p) : Calling glGetCompressedTexImage level %d, format %#x, type %#x, data %p.\n", surface, surface->texture_level, format->glFormat, format->glType, data.addr); @@ -1549,6 +1550,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P { const struct wined3d_format *src_format; const struct wined3d_format *dst_format; + unsigned int src_fmt_flags, dst_fmt_flags; const struct wined3d_gl_info *gl_info; struct wined3d_context *context; struct wined3d_bo_address data; @@ -1564,6 +1566,8 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P src_format = src_surface->resource.format; dst_format = dst_surface->resource.format; + src_fmt_flags = src_surface->resource.format_flags; + dst_fmt_flags = dst_surface->resource.format_flags; if (src_format->id != dst_format->id) { @@ -1611,14 +1615,14 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P return WINED3DERR_INVALIDCALL; } - if ((src_format->flags & WINED3DFMT_FLAG_BLOCKS) && !surface_check_block_align(src_surface, src_rect)) + if ((src_fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !surface_check_block_align(src_surface, src_rect)) { WARN("Source rectangle not block-aligned.\n"); return WINED3DERR_INVALIDCALL; } SetRect(&dst_rect, dst_point->x, dst_point->y, dst_point->x + update_w, dst_point->y + update_h); - if ((dst_format->flags & WINED3DFMT_FLAG_BLOCKS) && !surface_check_block_align(dst_surface, &dst_rect)) + if ((dst_fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !surface_check_block_align(dst_surface, &dst_rect)) { WARN("Destination rectangle not block-aligned.\n"); return WINED3DERR_INVALIDCALL; @@ -2507,6 +2511,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_desc *map_desc, const RECT *rect, DWORD flags) { const struct wined3d_format *format = surface->resource.format; + unsigned int fmt_flags = surface->resource.format_flags; struct wined3d_device *device = surface->resource.device; struct wined3d_context *context; const struct wined3d_gl_info *gl_info; @@ -2521,7 +2526,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, return WINED3DERR_INVALIDCALL; } - if ((format->flags & WINED3DFMT_FLAG_BLOCKS) && rect + if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && rect && !surface_check_block_align(surface, rect)) { WARN("Map rect %s is misaligned for %ux%u blocks.\n", @@ -2600,7 +2605,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, base_memory = NULL; } - if (format->flags & WINED3DFMT_FLAG_BROKEN_PITCH) + if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH) map_desc->row_pitch = surface->resource.width * format->byte_count; else map_desc->row_pitch = wined3d_surface_get_pitch(surface); @@ -2616,7 +2621,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, } else { - if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS) + if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS) { /* Compressed textures are block based, so calculate the offset of * the block that contains the top-left pixel of the locked rectangle. */ @@ -3981,7 +3986,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, } if (surface->locations & (WINED3D_LOCATION_TEXTURE_SRGB | WINED3D_LOCATION_TEXTURE_RGB) - && (surface->resource.format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB) + && (surface->resource.format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB) && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT, NULL, surface->resource.usage, surface->resource.pool, surface->resource.format, NULL, surface->resource.usage, surface->resource.pool, surface->resource.format)) @@ -3997,7 +4002,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, } if (surface->locations & (WINED3D_LOCATION_RB_MULTISAMPLE | WINED3D_LOCATION_RB_RESOLVED) - && (!srgb || (surface->resource.format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB)) + && (!srgb || (surface->resource.format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB)) && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT, NULL, surface->resource.usage, surface->resource.pool, surface->resource.format, NULL, surface->resource.usage, surface->resource.pool, surface->resource.format)) @@ -4554,6 +4559,7 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT * { int bpp, srcheight, srcwidth, dstheight, dstwidth, width; const struct wined3d_format *src_format, *dst_format; + unsigned int src_fmt_flags, dst_fmt_flags; struct wined3d_texture *src_texture = NULL; struct wined3d_map_desc dst_map, src_map; const BYTE *sbase = NULL; @@ -4572,10 +4578,13 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT * src_map = dst_map; src_format = dst_surface->resource.format; dst_format = src_format; + dst_fmt_flags = dst_surface->resource.format_flags; + src_fmt_flags = dst_fmt_flags; } else { dst_format = dst_surface->resource.format; + dst_fmt_flags = dst_surface->resource.format_flags; if (src_surface) { if (dst_surface->resource.format->id != src_surface->resource.format->id) @@ -4590,10 +4599,12 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT * } wined3d_surface_map(src_surface, &src_map, NULL, WINED3D_MAP_READONLY); src_format = src_surface->resource.format; + src_fmt_flags = src_surface->resource.format_flags; } else { src_format = dst_format; + src_fmt_flags = dst_fmt_flags; } wined3d_surface_map(dst_surface, &dst_map, dst_rect, 0); @@ -4617,7 +4628,7 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT * + ((dst_rect->top / dst_format->block_height) * dst_map.row_pitch) + ((dst_rect->left / dst_format->block_width) * dst_format->block_byte_count); - if (src_format->flags & dst_format->flags & WINED3DFMT_FLAG_BLOCKS) + if (src_fmt_flags & dst_fmt_flags & WINED3DFMT_FLAG_BLOCKS) { TRACE("%s -> %s copy.\n", debug_d3dformat(src_format->id), debug_d3dformat(dst_format->id)); @@ -5227,9 +5238,9 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC || src_rect.bottom - src_rect.top != dst_rect.bottom - dst_rect.top); convert = src_surface && src_surface->resource.format->id != dst_surface->resource.format->id; - dst_ds_flags = dst_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); + dst_ds_flags = dst_surface->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); if (src_surface) - src_ds_flags = src_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); + src_ds_flags = src_surface->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL); else src_ds_flags = 0; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 78d126615a1..de92e0e08ae 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -865,7 +865,7 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi GLsizei width = surface->pow2Width; const BYTE *mem = NULL; - if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE) + if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE) { height *= format->height_scale.numerator; height /= format->height_scale.denominator; @@ -898,7 +898,7 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi } } - if (format->flags & WINED3DFMT_FLAG_COMPRESSED && mem) + if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED && mem) { GL_EXTCALL(glCompressedTexImage2D(surface->texture_target, surface->texture_level, internal, width, height, 0, surface->resource.size, mem)); diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 357608fd789..b83ff2601dc 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -44,7 +44,7 @@ void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pit { const struct wined3d_format *format = volume->resource.format; - if (format->flags & WINED3DFMT_FLAG_BLOCKS) + if (volume->resource.format_flags & WINED3DFMT_FLAG_BLOCKS) { /* Since compressed formats are block based, pitch means the amount of * bytes to the next row of block rather than the next row of pixels. */ @@ -89,7 +89,7 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine if (data->buffer_object) ERR("Loading a converted volume from a PBO.\n"); - if (format->flags & WINED3DFMT_FLAG_BLOCKS) + if (volume->resource.format_flags & WINED3DFMT_FLAG_BLOCKS) ERR("Converting a block-based format.\n"); dst_row_pitch = width * format->conv_byte_count; @@ -551,6 +551,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, const struct wined3d_gl_info *gl_info; BYTE *base_memory; const struct wined3d_format *format = volume->resource.format; + const unsigned int fmt_flags = volume->resource.format_flags; TRACE("volume %p, map_desc %p, box %p, flags %#x.\n", volume, map_desc, box, flags); @@ -571,7 +572,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, WARN("Map box is invalid.\n"); return WINED3DERR_INVALIDCALL; } - if ((format->flags & WINED3DFMT_FLAG_BLOCKS) && !volume_check_block_align(volume, box)) + if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !volume_check_block_align(volume, box)) { WARN("Map box is misaligned for %ux%u blocks.\n", format->block_width, format->block_height); @@ -635,7 +636,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, TRACE("Base memory pointer %p.\n", base_memory); - if (format->flags & WINED3DFMT_FLAG_BROKEN_PITCH) + if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH) { map_desc->row_pitch = volume->resource.width * format->byte_count; map_desc->slice_pitch = map_desc->row_pitch * volume->resource.height; @@ -655,7 +656,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, TRACE("Lock Box (%p) = l %u, t %u, r %u, b %u, fr %u, ba %u\n", box, box->left, box->top, box->right, box->bottom, box->front, box->back); - if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS) + if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS) { /* Compressed textures are block based, so calculate the offset of * the block that contains the top-left pixel of the locked rectangle. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9b9973c6ffa..782f54f6d05 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2108,6 +2108,7 @@ struct wined3d_resource struct wined3d_device *device; enum wined3d_resource_type type; const struct wined3d_format *format; + unsigned int format_flags; enum wined3d_multisample_type multisample_type; UINT multisample_quality; DWORD usage;