From: Józef Kucia Subject: [PATCH resend 13/18] wined3d: Use depth/stencil formats for typeless resources only when WINED3DUSAGE_DEPTHSTENCIL is set. Message-Id: <1481279453-9357-13-git-send-email-jkucia@codeweavers.com> Date: Fri, 9 Dec 2016 11:30:48 +0100 In-Reply-To: <1481279453-9357-1-git-send-email-jkucia@codeweavers.com> References: <1481279453-9357-1-git-send-email-jkucia@codeweavers.com> Signed-off-by: Józef Kucia --- dlls/wined3d/buffer.c | 2 +- dlls/wined3d/context.c | 12 ++++--- dlls/wined3d/directx.c | 19 +++++----- dlls/wined3d/surface.c | 2 +- dlls/wined3d/swapchain.c | 4 +-- dlls/wined3d/texture.c | 13 ++++--- dlls/wined3d/utils.c | 76 ++++++++++++++++++++++++++++++---------- dlls/wined3d/vertexdeclaration.c | 4 +-- dlls/wined3d/view.c | 6 ++-- dlls/wined3d/wined3d_private.h | 2 +- 10 files changed, 92 insertions(+), 48 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 58c273c..d326a70 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1446,7 +1446,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops) { const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - const struct wined3d_format *format = wined3d_get_format(gl_info, format_id); + const struct wined3d_format *format = wined3d_get_format(gl_info, format_id, usage); BOOL dynamic_buffer_ok; HRESULT hr; diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 6623c03..b8ffb6c 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1641,6 +1641,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, BOOL hdc_is_private = FALSE; BOOL auxBuffers = FALSE; HGLRC ctx, share_ctx; + DWORD target_usage; int pixel_format; unsigned int s; DWORD state; @@ -1725,6 +1726,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, } color_format = target->resource.format; + target_usage = target->resource.usage; /* In case of ORM_BACKBUFFER, make sure to request an alpha component for * X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */ @@ -1733,9 +1735,9 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, auxBuffers = TRUE; if (color_format->id == WINED3DFMT_B4G4R4X4_UNORM) - color_format = wined3d_get_format(gl_info, WINED3DFMT_B4G4R4A4_UNORM); + color_format = wined3d_get_format(gl_info, WINED3DFMT_B4G4R4A4_UNORM, target_usage); else if (color_format->id == WINED3DFMT_B8G8R8X8_UNORM) - color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM); + color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage); } /* DirectDraw supports 8bit paletted render targets and these are used by @@ -1745,7 +1747,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, * For this reason we require a format with 8bit alpha, so request * A8R8G8B8. */ if (color_format->id == WINED3DFMT_P8_UINT) - color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM); + color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage); /* When "always_offscreen" is enabled, we only use the drawable for * presentation blits, and don't do any rendering to it. That means we @@ -1758,8 +1760,8 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, if (wined3d_settings.offscreen_rendering_mode != ORM_BACKBUFFER && wined3d_settings.always_offscreen) { - color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM); - ds_format = wined3d_get_format(gl_info, WINED3DFMT_UNKNOWN); + color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage); + ds_format = wined3d_get_format(gl_info, WINED3DFMT_UNKNOWN, WINED3DUSAGE_DEPTHSTENCIL); } /* Try to find a pixel format which matches our requirements. */ diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 34c42be..1aae20d 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4180,7 +4180,7 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad return 0; adapter = &wined3d->adapters[adapter_idx]; - format = wined3d_get_format(&adapter->gl_info, format_id); + format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET); format_bits = format->byte_count * CHAR_BIT; memset(&mode, 0, sizeof(mode)); @@ -4234,7 +4234,7 @@ HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT ada return WINED3DERR_INVALIDCALL; adapter = &wined3d->adapters[adapter_idx]; - format = wined3d_get_format(&adapter->gl_info, format_id); + format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET); format_bits = format->byte_count * CHAR_BIT; memset(&m, 0, sizeof(m)); @@ -4493,7 +4493,7 @@ HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d, TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id), mode->scanline_ordering); - format = wined3d_get_format(&adapter->gl_info, mode->format_id); + format = wined3d_get_format(&adapter->gl_info, mode->format_id, WINED3DUSAGE_RENDERTARGET); new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT; @@ -4734,8 +4734,8 @@ HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d, return WINED3DERR_INVALIDCALL; adapter = &wined3d->adapters[adapter_idx]; - rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id); - ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id); + rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id, WINED3DUSAGE_RENDERTARGET); + ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id, WINED3DUSAGE_DEPTHSTENCIL); if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET) @@ -4776,7 +4776,7 @@ HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3 enum wined3d_multisample_type multisample_type, DWORD *quality_levels) { const struct wined3d_gl_info *gl_info = &wined3d->adapters[adapter_idx].gl_info; - const struct wined3d_format *format = wined3d_get_format(gl_info, surface_format_id); + const struct wined3d_format *format = wined3d_get_format(gl_info, surface_format_id, 0); HRESULT hr = WINED3D_OK; TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, " @@ -4979,8 +4979,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad { const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx]; const struct wined3d_gl_info *gl_info = &adapter->gl_info; - const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id); - const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id); + const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id, + WINED3DUSAGE_RENDERTARGET); + const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id, usage); DWORD format_flags = 0; DWORD allowed_usage; enum wined3d_gl_resource_type gl_type; @@ -5130,7 +5131,7 @@ UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT ad return ~0u; gl_info = &wined3d->adapters[adapter_idx].gl_info; - wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id), + wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id, 0), 1, width, 1, &row_pitch, &slice_pitch); return row_pitch; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index bd5d2f6..18b008c 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2907,7 +2907,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, format = *texture->resource.format; if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE))) - format = *wined3d_get_format(gl_info, conversion->dst_format); + format = *wined3d_get_format(gl_info, conversion->dst_format, texture->resource.usage); /* Don't use PBOs for converted surfaces. During PBO conversion we look at * WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 2dfa489..7bbcc86 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -795,7 +795,7 @@ static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_s return; gl_info = &swapchain->device->adapter->gl_info; - if (!(format = wined3d_get_format(gl_info, format_id))) + if (!(format = wined3d_get_format(gl_info, format_id, WINED3DUSAGE_RENDERTARGET))) return; if ((t = min(wined3d_settings.sample_count, gl_info->limits.samples))) @@ -961,7 +961,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 * issue needs to be fixed. */ for (i = 0; i < (sizeof(formats) / sizeof(*formats)); i++) { - swapchain->ds_format = wined3d_get_format(gl_info, formats[i]); + swapchain->ds_format = wined3d_get_format(gl_info, formats[i], WINED3DUSAGE_DEPTHSTENCIL); swapchain->context[0] = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format); if (swapchain->context[0]) break; TRACE("Depth stencil format %s is not supported, trying next format\n", diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index b1dca69..a24a492 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -262,8 +262,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops) { - const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, desc->format); unsigned int i, j, size, offset = 0; + const struct wined3d_format *format; HRESULT hr; TRACE("texture %p, texture_ops %p, layer_count %u, level_count %u, resource_type %s, format %s, " @@ -277,6 +277,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc if (!desc->width || !desc->height || !desc->depth) return WINED3DERR_INVALIDCALL; + format = wined3d_get_format(&device->adapter->gl_info, desc->format, desc->usage); + for (i = 0; i < layer_count; ++i) { for (j = 0; j < level_count; ++j) @@ -1090,7 +1092,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT { struct wined3d_device *device = texture->resource.device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - const struct wined3d_format *format = wined3d_get_format(gl_info, format_id); + const struct wined3d_format *format = wined3d_get_format(gl_info, format_id, texture->resource.usage); UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1); struct wined3d_texture_sub_resource *sub_resource; struct wined3d_surface *surface; @@ -1495,7 +1497,7 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE))) { texture->flags |= WINED3D_TEXTURE_CONVERTED; - format = wined3d_get_format(gl_info, conversion->dst_format); + format = wined3d_get_format(gl_info, conversion->dst_format, texture->resource.usage); TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id)); } @@ -1931,7 +1933,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 if (!gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]) { - const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format); + const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format, desc->usage); /* TODO: Add support for non-power-of-two compressed textures. */ if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] @@ -2809,7 +2811,8 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct if (desc->multisample_type != WINED3D_MULTISAMPLE_NONE) { - const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, desc->format); + const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, + desc->format, desc->usage); if (desc->multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE && desc->multisample_quality >= wined3d_popcount(format->multisample_types)) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a7d0deb..623a462 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -237,10 +237,10 @@ static const struct wined3d_typed_format_info typed_formats[] = {WINED3DFMT_R16G16_UINT, WINED3DFMT_R16G16_TYPELESS, "UU"}, {WINED3DFMT_R16G16_SINT, WINED3DFMT_R16G16_TYPELESS, "II"}, {WINED3DFMT_R16G16_FLOAT, WINED3DFMT_R16G16_TYPELESS, "FF"}, + {WINED3DFMT_D32_FLOAT, WINED3DFMT_R32_TYPELESS, "D"}, {WINED3DFMT_R32_UINT, WINED3DFMT_R32_TYPELESS, "U"}, {WINED3DFMT_R32_SINT, WINED3DFMT_R32_TYPELESS, "I"}, {WINED3DFMT_R32_FLOAT, WINED3DFMT_R32_TYPELESS, "F"}, - {WINED3DFMT_D32_FLOAT, WINED3DFMT_R32_TYPELESS, "D"}, {WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_R24G8_TYPELESS, "DX"}, {WINED3DFMT_X24_TYPELESS_G8_UINT, WINED3DFMT_R24G8_TYPELESS, "XS"}, {WINED3DFMT_D24_UNORM_S8_UINT, WINED3DFMT_R24G8_TYPELESS, "DS"}, @@ -248,12 +248,12 @@ static const struct wined3d_typed_format_info typed_formats[] = {WINED3DFMT_R8G8_UNORM, WINED3DFMT_R8G8_TYPELESS, "uu"}, {WINED3DFMT_R8G8_UINT, WINED3DFMT_R8G8_TYPELESS, "UU"}, {WINED3DFMT_R8G8_SINT, WINED3DFMT_R8G8_TYPELESS, "II"}, + {WINED3DFMT_D16_UNORM, WINED3DFMT_R16_TYPELESS, "D"}, {WINED3DFMT_R16_UNORM, WINED3DFMT_R16_TYPELESS, "u"}, {WINED3DFMT_R16_SNORM, WINED3DFMT_R16_TYPELESS, "i"}, {WINED3DFMT_R16_UINT, WINED3DFMT_R16_TYPELESS, "U"}, {WINED3DFMT_R16_SINT, WINED3DFMT_R16_TYPELESS, "I"}, {WINED3DFMT_R16_FLOAT, WINED3DFMT_R16_TYPELESS, "F"}, - {WINED3DFMT_D16_UNORM, WINED3DFMT_R16_TYPELESS, "D"}, {WINED3DFMT_R8_UNORM, WINED3DFMT_R8_TYPELESS, "u"}, {WINED3DFMT_R8_SNORM, WINED3DFMT_R8_TYPELESS, "i"}, {WINED3DFMT_R8_UINT, WINED3DFMT_R8_TYPELESS, "U"}, @@ -276,17 +276,22 @@ static const struct wined3d_typed_format_info typed_formats[] = {WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_B8G8R8X8_TYPELESS, "uuuX"}, }; -struct wined3d_format_typeless_depth_stencil_info +struct wined3d_typeless_format_depth_stencil_info { + enum wined3d_format_id typeless_id; enum wined3d_format_id depth_stencil_id; enum wined3d_format_id depth_view_id; enum wined3d_format_id stencil_view_id; }; -static const struct wined3d_format_typeless_depth_stencil_info typeless_depth_stencil_formats[] = +static const struct wined3d_typeless_format_depth_stencil_info typeless_depth_stencil_formats[] = { - {WINED3DFMT_D32_FLOAT_S8X24_UINT, WINED3DFMT_R32_FLOAT_X8X24_TYPELESS, WINED3DFMT_X32_TYPELESS_G8X24_UINT}, - {WINED3DFMT_D24_UNORM_S8_UINT, WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_X24_TYPELESS_G8_UINT}, + {WINED3DFMT_R32G8X24_TYPELESS, WINED3DFMT_D32_FLOAT_S8X24_UINT, + WINED3DFMT_R32_FLOAT_X8X24_TYPELESS, WINED3DFMT_X32_TYPELESS_G8X24_UINT}, + {WINED3DFMT_R24G8_TYPELESS, WINED3DFMT_D24_UNORM_S8_UINT, + WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_X24_TYPELESS_G8_UINT}, + {WINED3DFMT_R32_TYPELESS, WINED3DFMT_D32_FLOAT}, + {WINED3DFMT_R16_TYPELESS, WINED3DFMT_D16_UNORM}, }; struct wined3d_format_ddi_info @@ -1747,7 +1752,8 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info) unsigned int i, j; gl_info->format_count = WINED3D_FORMAT_COUNT; - if (!(gl_info->formats = wined3d_calloc(gl_info->format_count, sizeof(*gl_info->formats)))) + if (!(gl_info->formats = wined3d_calloc(gl_info->format_count + + ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*gl_info->formats)))) { ERR("Failed to allocate memory.\n"); return FALSE; @@ -3424,17 +3430,33 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info) for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i) { - struct wined3d_format *ds_format, *depth_view_format, *stencil_view_format; + struct wined3d_format *typeless_format, *typeless_ds_format, *ds_format; + struct wined3d_format *depth_view_format, *stencil_view_format; + enum wined3d_format_id format_id; - if (!(ds_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].depth_stencil_id))) - return FALSE; - if (!(depth_view_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].depth_view_id))) + if (!(typeless_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].typeless_id))) return FALSE; - if (!(stencil_view_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].stencil_view_id))) + if (!(ds_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].depth_stencil_id))) return FALSE; - copy_format(depth_view_format, ds_format); - copy_format(stencil_view_format, ds_format); + typeless_ds_format = &gl_info->formats[WINED3D_FORMAT_COUNT + i]; + typeless_ds_format->id = typeless_depth_stencil_formats[i].typeless_id; + copy_format(typeless_ds_format, ds_format); + for (j = 0; j < ARRAY_SIZE(typeless_ds_format->flags); ++j) + typeless_ds_format->flags[j] = typeless_format->flags[j]; + + if ((format_id = typeless_depth_stencil_formats[i].depth_view_id)) + { + if (!(depth_view_format = get_format_internal(gl_info, format_id))) + return FALSE; + copy_format(depth_view_format, ds_format); + } + if ((format_id = typeless_depth_stencil_formats[i].stencil_view_id)) + { + if (!(stencil_view_format = get_format_internal(gl_info, format_id))) + return FALSE; + copy_format(stencil_view_format, ds_format); + } } return TRUE; @@ -3573,19 +3595,35 @@ float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLe } const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info, - enum wined3d_format_id format_id) + enum wined3d_format_id format_id, unsigned int resource_usage) { + const struct wined3d_format *format; int idx = get_format_idx(format_id); + unsigned int i; if (idx == -1) { - FIXME("Can't find format %s (%#x) in the format lookup table\n", + FIXME("Can't find format %s (%#x) in the format lookup table.\n", + debug_d3dformat(format_id), format_id); + return &gl_info->formats[get_format_idx(WINED3DFMT_UNKNOWN)]; + } + + format = &gl_info->formats[idx]; + + if (resource_usage & WINED3DUSAGE_DEPTHSTENCIL && wined3d_format_is_typeless(format)) + { + for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i) + { + if (typeless_depth_stencil_formats[i].typeless_id == format_id) + return &gl_info->formats[WINED3D_FORMAT_COUNT + i]; + } + + FIXME("Cannot find depth/stencil typeless format %s (%#x).\n", debug_d3dformat(format_id), format_id); - /* Get the caller a valid pointer */ - idx = get_format_idx(WINED3DFMT_UNKNOWN); + return &gl_info->formats[get_format_idx(WINED3DFMT_UNKNOWN)]; } - return &gl_info->formats[idx]; + return format; } void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment, diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index 70c2d98..61c82d3 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -201,7 +201,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara { struct wined3d_vertex_declaration_element *e = &declaration->elements[i]; - e->format = wined3d_get_format(gl_info, elements[i].format); + e->format = wined3d_get_format(gl_info, elements[i].format, 0); e->ffp_valid = declaration_element_valid_ffp(&elements[i]); e->input_slot = elements[i].input_slot; e->offset = elements[i].offset; @@ -314,7 +314,7 @@ static void append_decl_element(struct wined3d_fvf_convert_state *state, elements[idx].usage = usage; elements[idx].usage_idx = usage_idx; - format = wined3d_get_format(state->gl_info, format_id); + format = wined3d_get_format(state->gl_info, format_id, 0); state->offset += format->attribute_size; ++state->idx; } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 8ad255b..566db3a 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -245,7 +245,7 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view * view->parent = parent; view->parent_ops = parent_ops; - view->format = wined3d_get_format(gl_info, desc->format_id); + view->format = wined3d_get_format(gl_info, desc->format_id, resource->usage); view->format_flags = view->format->flags[resource->gl_type]; if (wined3d_format_is_typeless(view->format)) @@ -401,7 +401,7 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_ const struct wined3d_format *view_format; GLenum view_target; - view_format = wined3d_get_format(gl_info, desc->format_id); + view_format = wined3d_get_format(gl_info, desc->format_id, resource->usage); if (wined3d_format_is_typeless(view_format) && !(view_format->id == WINED3DFMT_R32_TYPELESS && (desc->flags & WINED3D_VIEW_BUFFER_RAW))) { @@ -578,7 +578,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces view->parent = parent; view->parent_ops = parent_ops; - view->format = wined3d_get_format(gl_info, desc->format_id); + view->format = wined3d_get_format(gl_info, desc->format_id, resource->usage); if (wined3d_format_is_typeless(view->format) && !(view->format->id == WINED3DFMT_R32_TYPELESS && (desc->flags & WINED3D_VIEW_BUFFER_RAW))) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 69ba146..e788f59 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3789,7 +3789,7 @@ struct wined3d_format }; const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info, - enum wined3d_format_id format_id) DECLSPEC_HIDDEN; + enum wined3d_format_id format_id, unsigned int resource_usage) DECLSPEC_HIDDEN; void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment, unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN; UINT wined3d_format_calculate_size(const struct wined3d_format *format, -- 2.7.3