Commit 5ee3f544 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Use single structure for view description.

parent 663dee14
......@@ -1209,7 +1209,7 @@ static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl =
d3d10_depthstencil_view_GetDesc,
};
static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarget_view_desc *wined3d_desc,
static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_view_desc *wined3d_desc,
const D3D11_DEPTH_STENCIL_VIEW_DESC *desc)
{
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
......@@ -1217,6 +1217,8 @@ static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarg
if (desc->Flags)
FIXME("Unhandled depth stencil view flags %#x.\n", desc->Flags);
wined3d_desc->flags = 0;
wined3d_desc->u.texture.level_count = 1;
switch (desc->ViewDimension)
{
case D3D11_DSV_DIMENSION_TEXTURE1D:
......@@ -1226,6 +1228,7 @@ static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarg
break;
case D3D11_DSV_DIMENSION_TEXTURE1DARRAY:
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
wined3d_desc->u.texture.level_idx = desc->u.Texture1DArray.MipSlice;
wined3d_desc->u.texture.layer_idx = desc->u.Texture1DArray.FirstArraySlice;
wined3d_desc->u.texture.layer_count = desc->u.Texture1DArray.ArraySize;
......@@ -1238,6 +1241,7 @@ static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarg
break;
case D3D11_DSV_DIMENSION_TEXTURE2DARRAY:
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
wined3d_desc->u.texture.level_idx = desc->u.Texture2DArray.MipSlice;
wined3d_desc->u.texture.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
wined3d_desc->u.texture.layer_count = desc->u.Texture2DArray.ArraySize;
......@@ -1250,6 +1254,7 @@ static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarg
break;
case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY:
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
wined3d_desc->u.texture.level_idx = 0;
wined3d_desc->u.texture.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
wined3d_desc->u.texture.layer_count = desc->u.Texture2DMSArray.ArraySize;
......@@ -1267,8 +1272,8 @@ static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarg
static HRESULT d3d_depthstencil_view_init(struct d3d_depthstencil_view *view, struct d3d_device *device,
ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc)
{
struct wined3d_rendertarget_view_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
struct wined3d_view_desc wined3d_desc;
HRESULT hr;
view->ID3D11DepthStencilView_iface.lpVtbl = &d3d11_depthstencil_view_vtbl;
......@@ -1624,11 +1629,13 @@ static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
d3d10_rendertarget_view_GetDesc,
};
static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarget_view_desc *wined3d_desc,
static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_view_desc *wined3d_desc,
const D3D11_RENDER_TARGET_VIEW_DESC *desc)
{
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
wined3d_desc->flags = 0;
wined3d_desc->u.texture.level_count = 1;
switch (desc->ViewDimension)
{
case D3D11_RTV_DIMENSION_BUFFER:
......@@ -1643,6 +1650,7 @@ static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarge
break;
case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
wined3d_desc->u.texture.level_idx = desc->u.Texture1DArray.MipSlice;
wined3d_desc->u.texture.layer_idx = desc->u.Texture1DArray.FirstArraySlice;
wined3d_desc->u.texture.layer_count = desc->u.Texture1DArray.ArraySize;
......@@ -1655,6 +1663,7 @@ static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarge
break;
case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
wined3d_desc->u.texture.level_idx = desc->u.Texture2DArray.MipSlice;
wined3d_desc->u.texture.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
wined3d_desc->u.texture.layer_count = desc->u.Texture2DArray.ArraySize;
......@@ -1667,6 +1676,7 @@ static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarge
break;
case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
wined3d_desc->u.texture.level_idx = 0;
wined3d_desc->u.texture.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
wined3d_desc->u.texture.layer_count = desc->u.Texture2DMSArray.ArraySize;
......@@ -1690,8 +1700,8 @@ static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarge
static HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device,
ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc)
{
struct wined3d_rendertarget_view_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
struct wined3d_view_desc wined3d_desc;
HRESULT hr;
view->ID3D11RenderTargetView_iface.lpVtbl = &d3d11_rendertarget_view_vtbl;
......@@ -2071,7 +2081,7 @@ static unsigned int wined3d_view_flags_from_d3d11_bufferex_flags(unsigned int d3
return wined3d_flags;
}
static HRESULT wined3d_shader_resource_view_desc_from_d3d11(struct wined3d_shader_resource_view_desc *wined3d_desc,
static HRESULT wined3d_shader_resource_view_desc_from_d3d11(struct wined3d_view_desc *wined3d_desc,
const D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
{
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
......@@ -2169,8 +2179,8 @@ static HRESULT wined3d_shader_resource_view_desc_from_d3d11(struct wined3d_shade
static HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *view, struct d3d_device *device,
ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
{
struct wined3d_shader_resource_view_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
struct wined3d_view_desc wined3d_desc;
HRESULT hr;
view->ID3D11ShaderResourceView_iface.lpVtbl = &d3d11_shader_resource_view_vtbl;
......@@ -2402,12 +2412,13 @@ static unsigned int wined3d_view_flags_from_d3d11_buffer_uav_flags(unsigned int
return wined3d_flags;
}
static HRESULT wined3d_unordered_access_view_desc_from_d3d11(struct wined3d_unordered_access_view_desc *wined3d_desc,
static HRESULT wined3d_unordered_access_view_desc_from_d3d11(struct wined3d_view_desc *wined3d_desc,
const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc)
{
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
wined3d_desc->flags = 0;
wined3d_desc->flags = 0;
wined3d_desc->u.texture.level_count = 1;
switch (desc->ViewDimension)
{
case D3D11_UAV_DIMENSION_BUFFER:
......@@ -2459,8 +2470,8 @@ static HRESULT wined3d_unordered_access_view_desc_from_d3d11(struct wined3d_unor
static HRESULT d3d11_unordered_access_view_init(struct d3d11_unordered_access_view *view,
struct d3d_device *device, ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc)
{
struct wined3d_unordered_access_view_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
struct wined3d_view_desc wined3d_desc;
HRESULT hr;
view->ID3D11UnorderedAccessView_iface.lpVtbl = &d3d11_unordered_access_view_vtbl;
......
......@@ -1035,10 +1035,12 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
if (swapchain_desc->backbuffer_count)
{
struct wined3d_resource *back_buffer = &swapchain->back_buffers[0]->resource;
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_view_desc view_desc;
view_desc.format_id = back_buffer->format->id;
view_desc.flags = 0;
view_desc.u.texture.level_idx = 0;
view_desc.u.texture.level_count = 1;
view_desc.u.texture.layer_idx = 0;
view_desc.u.texture.layer_count = 1;
if (FAILED(hr = wined3d_rendertarget_view_create(&view_desc, back_buffer,
......@@ -4636,9 +4638,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode,
wined3d_device_reset_cb callback, BOOL reset_state)
{
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_resource *resource, *cursor;
struct wined3d_swapchain *swapchain;
struct wined3d_view_desc view_desc;
BOOL backbuffer_resized;
HRESULT hr = WINED3D_OK;
unsigned int i;
......@@ -4792,7 +4794,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
}
view_desc.format_id = texture->resource.format->id;
view_desc.flags = 0;
view_desc.u.texture.level_idx = 0;
view_desc.u.texture.level_count = 1;
view_desc.u.texture.layer_idx = 0;
view_desc.u.texture.layer_count = 1;
hr = wined3d_rendertarget_view_create(&view_desc, &texture->resource,
......@@ -4817,7 +4821,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
struct wined3d_resource *back_buffer = &swapchain->back_buffers[0]->resource;
view_desc.format_id = back_buffer->format->id;
view_desc.flags = 0;
view_desc.u.texture.level_idx = 0;
view_desc.u.texture.level_count = 1;
view_desc.u.texture.layer_idx = 0;
view_desc.u.texture.layer_count = 1;
if (FAILED(hr = wined3d_rendertarget_view_create(&view_desc, back_buffer,
......
......@@ -675,8 +675,8 @@ static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const
{
struct wined3d_resource *resource = &surface->container->resource;
struct wined3d_device *device = resource->device;
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_rendertarget_view *view;
struct wined3d_view_desc view_desc;
const struct blit_shader *blitter;
HRESULT hr;
......@@ -688,7 +688,9 @@ static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const
}
view_desc.format_id = resource->format->id;
view_desc.flags = 0;
view_desc.u.texture.level_idx = surface->texture_level;
view_desc.u.texture.level_count = 1;
view_desc.u.texture.layer_idx = surface->texture_layer;
view_desc.u.texture.layer_count = 1;
if (FAILED(hr = wined3d_rendertarget_view_create(&view_desc,
......@@ -2319,8 +2321,8 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
{
struct wined3d_resource *resource = &s->container->resource;
struct wined3d_device *device = resource->device;
struct wined3d_rendertarget_view_desc view_desc;
struct wined3d_rendertarget_view *view;
struct wined3d_view_desc view_desc;
const struct blit_shader *blitter;
HRESULT hr;
......@@ -2332,7 +2334,9 @@ HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const st
}
view_desc.format_id = resource->format->id;
view_desc.flags = 0;
view_desc.u.texture.level_idx = s->texture_level;
view_desc.u.texture.level_count = 1;
view_desc.u.texture.layer_idx = s->texture_layer;
view_desc.u.texture.layer_count = 1;
if (FAILED(hr = wined3d_rendertarget_view_create(&view_desc,
......
......@@ -1016,8 +1016,8 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
TRACE("Creating depth/stencil buffer.\n");
if (!device->auto_depth_stencil_view)
{
struct wined3d_view_desc desc;
struct wined3d_texture *ds;
struct wined3d_rendertarget_view_desc desc;
texture_desc.format = swapchain->desc.auto_depth_stencil_format;
texture_desc.usage = WINED3DUSAGE_DEPTHSTENCIL;
......@@ -1030,7 +1030,9 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
}
desc.format_id = ds->resource.format->id;
desc.flags = 0;
desc.u.texture.level_idx = 0;
desc.u.texture.level_count = 1;
desc.u.texture.layer_idx = 0;
desc.u.texture.layer_count = 1;
hr = wined3d_rendertarget_view_create(&desc, &ds->resource, NULL, &wined3d_null_parent_ops,
......
......@@ -145,7 +145,7 @@ void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarg
}
static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
const struct wined3d_rendertarget_view_desc *desc, struct wined3d_resource *resource,
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &resource->device->adapter->gl_info;
......@@ -182,6 +182,7 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
depth_or_layer_count = texture->layer_count;
if (desc->u.texture.level_idx >= texture->level_count
|| desc->u.texture.level_count != 1
|| desc->u.texture.layer_idx >= depth_or_layer_count
|| !desc->u.texture.layer_count
|| desc->u.texture.layer_count > depth_or_layer_count - desc->u.texture.layer_idx)
......@@ -200,7 +201,7 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
return WINED3D_OK;
}
HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc,
HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_rendertarget_view **view)
{
......@@ -230,13 +231,15 @@ HRESULT CDECL wined3d_rendertarget_view_create_from_sub_resource(struct wined3d_
unsigned int sub_resource_idx, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_rendertarget_view **view)
{
struct wined3d_rendertarget_view_desc desc;
struct wined3d_view_desc desc;
TRACE("texture %p, sub_resource_idx %u, parent %p, parent_ops %p, view %p.\n",
texture, sub_resource_idx, parent, parent_ops, view);
desc.format_id = texture->resource.format->id;
desc.flags = 0;
desc.u.texture.level_idx = sub_resource_idx % texture->level_count;
desc.u.texture.level_count = 1;
desc.u.texture.layer_idx = sub_resource_idx / texture->level_count;
desc.u.texture.layer_count = 1;
......@@ -300,7 +303,7 @@ void * CDECL wined3d_shader_resource_view_get_parent(const struct wined3d_shader
}
static void wined3d_shader_resource_view_create_texture_view(struct wined3d_shader_resource_view *view,
const struct wined3d_shader_resource_view_desc *desc, struct wined3d_texture *texture,
const struct wined3d_view_desc *desc, struct wined3d_texture *texture,
const struct wined3d_format *view_format)
{
const struct wined3d_gl_info *gl_info;
......@@ -349,7 +352,7 @@ static void wined3d_shader_resource_view_create_texture_view(struct wined3d_shad
}
static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_view *view,
const struct wined3d_shader_resource_view_desc *desc, struct wined3d_resource *resource,
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
static const struct
......@@ -441,7 +444,7 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_
return WINED3D_OK;
}
HRESULT CDECL wined3d_shader_resource_view_create(const struct wined3d_shader_resource_view_desc *desc,
HRESULT CDECL wined3d_shader_resource_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_shader_resource_view **view)
{
......@@ -552,7 +555,7 @@ void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_
}
static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_access_view *view,
const struct wined3d_unordered_access_view_desc *desc, struct wined3d_resource *resource,
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &resource->device->adapter->gl_info;
......@@ -580,6 +583,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
depth_or_layer_count = texture->layer_count;
if (desc->u.texture.level_idx >= texture->level_count
|| desc->u.texture.level_count != 1
|| desc->u.texture.layer_idx >= depth_or_layer_count
|| !desc->u.texture.layer_count
|| desc->u.texture.layer_count > depth_or_layer_count - desc->u.texture.layer_idx)
......@@ -600,7 +604,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
return WINED3D_OK;
}
HRESULT CDECL wined3d_unordered_access_view_create(const struct wined3d_unordered_access_view_desc *desc,
HRESULT CDECL wined3d_unordered_access_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_unordered_access_view **view)
{
......
......@@ -1914,25 +1914,6 @@ struct wined3d_rasterizer_state_desc
BOOL front_ccw;
};
struct wined3d_rendertarget_view_desc
{
enum wined3d_format_id format_id;
union
{
struct
{
unsigned int start_idx;
unsigned int count;
} buffer;
struct
{
unsigned int level_idx;
unsigned int layer_idx;
unsigned int layer_count;
} texture;
} u;
};
struct wined3d_sampler_desc
{
enum wined3d_texture_address address_u;
......@@ -1975,7 +1956,7 @@ struct wined3d_shader_desc
unsigned int max_version;
};
struct wined3d_shader_resource_view_desc
struct wined3d_view_desc
{
enum wined3d_format_id format_id;
unsigned int flags;
......@@ -1996,26 +1977,6 @@ struct wined3d_shader_resource_view_desc
} u;
};
struct wined3d_unordered_access_view_desc
{
enum wined3d_format_id format_id;
unsigned int flags;
union
{
struct
{
unsigned int start_idx;
unsigned int count;
} buffer;
struct
{
unsigned int level_idx;
unsigned int layer_idx;
unsigned int layer_count;
} texture;
} u;
};
struct wined3d_output_desc
{
WCHAR device_name[CCHDEVICENAME];
......@@ -2467,7 +2428,7 @@ void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void
DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority);
HRESULT __cdecl wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx);
HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_rendertarget_view_desc *desc,
HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_rendertarget_view **view);
HRESULT __cdecl wined3d_rendertarget_view_create_from_sub_resource(struct wined3d_texture *texture,
......@@ -2506,7 +2467,7 @@ ULONG __cdecl wined3d_shader_incref(struct wined3d_shader *shader);
HRESULT __cdecl wined3d_shader_set_local_constants_float(struct wined3d_shader *shader,
UINT start_idx, const float *src_data, UINT vector4f_count);
HRESULT __cdecl wined3d_shader_resource_view_create(const struct wined3d_shader_resource_view_desc *desc,
HRESULT __cdecl wined3d_shader_resource_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_shader_resource_view **view);
ULONG __cdecl wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view);
......@@ -2595,7 +2556,7 @@ HRESULT __cdecl wined3d_texture_update_overlay(struct wined3d_texture *texture,
const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
const RECT *dst_rect, DWORD flags);
HRESULT __cdecl wined3d_unordered_access_view_create(const struct wined3d_unordered_access_view_desc *desc,
HRESULT __cdecl wined3d_unordered_access_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_unordered_access_view **view);
ULONG __cdecl wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment