mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
d3d11: Implement d3d11_texture2d_GetDesc().
This commit is contained in:
parent
9427d1d553
commit
acec54e707
@ -66,6 +66,15 @@ DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage) DECL
|
||||
struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN;
|
||||
DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type) DECLSPEC_HIDDEN;
|
||||
|
||||
enum D3D11_USAGE d3d11_usage_from_d3d10_usage(enum D3D10_USAGE usage) DECLSPEC_HIDDEN;
|
||||
enum D3D10_USAGE d3d10_usage_from_d3d11_usage(enum D3D11_USAGE usage) DECLSPEC_HIDDEN;
|
||||
UINT d3d11_bind_flags_from_d3d10_bind_flags(UINT bind_flags) DECLSPEC_HIDDEN;
|
||||
UINT d3d10_bind_flags_from_d3d11_bind_flags(UINT bind_flags) DECLSPEC_HIDDEN;
|
||||
UINT d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(UINT cpu_access_flags) DECLSPEC_HIDDEN;
|
||||
UINT d3d10_cpu_access_flags_from_d3d11_cpu_access_flags(UINT cpu_access_flags) DECLSPEC_HIDDEN;
|
||||
UINT d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(UINT resource_misc_flags) DECLSPEC_HIDDEN;
|
||||
UINT d3d10_resource_misc_flags_from_d3d11_resource_misc_flags(UINT resource_misc_flags) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT d3d10_get_private_data(struct wined3d_private_store *store,
|
||||
REFGUID guid, UINT *data_size, void *data) DECLSPEC_HIDDEN;
|
||||
HRESULT d3d10_set_private_data(struct wined3d_private_store *store,
|
||||
@ -84,7 +93,7 @@ void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
|
||||
HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
||||
HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ID3D10Texture2D */
|
||||
/* ID3D11Texture2D, ID3D10Texture2D */
|
||||
struct d3d10_texture2d
|
||||
{
|
||||
ID3D11Texture2D ID3D11Texture2D_iface;
|
||||
@ -94,7 +103,7 @@ struct d3d10_texture2d
|
||||
struct wined3d_private_store private_store;
|
||||
IUnknown *dxgi_surface;
|
||||
struct wined3d_texture *wined3d_texture;
|
||||
D3D10_TEXTURE2D_DESC desc;
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ID3D11Device *device;
|
||||
};
|
||||
|
||||
@ -104,7 +113,7 @@ static inline struct d3d10_texture2d *impl_from_ID3D10Texture2D(ID3D10Texture2D
|
||||
}
|
||||
|
||||
HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device *device,
|
||||
const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *initial_data) DECLSPEC_HIDDEN;
|
||||
const D3D11_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *initial_data) DECLSPEC_HIDDEN;
|
||||
struct d3d10_texture2d *unsafe_impl_from_ID3D10Texture2D(ID3D10Texture2D *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ID3D10Texture3D */
|
||||
|
@ -1601,6 +1601,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *ifa
|
||||
ID3D10Texture2D **texture)
|
||||
{
|
||||
struct d3d_device *device = impl_from_ID3D10Device(iface);
|
||||
D3D11_TEXTURE2D_DESC d3d11_desc;
|
||||
struct d3d10_texture2d *object;
|
||||
HRESULT hr;
|
||||
|
||||
@ -1610,7 +1611,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *ifa
|
||||
if (!object)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = d3d10_texture2d_init(object, device, desc, data)))
|
||||
d3d11_desc.Width = desc->Width;
|
||||
d3d11_desc.Height = desc->Height;
|
||||
d3d11_desc.MipLevels = desc->MipLevels;
|
||||
d3d11_desc.ArraySize = desc->ArraySize;
|
||||
d3d11_desc.Format = desc->Format;
|
||||
d3d11_desc.SampleDesc = desc->SampleDesc;
|
||||
d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
|
||||
d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
|
||||
d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
|
||||
d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
|
||||
|
||||
if (FAILED(hr = d3d10_texture2d_init(object, device, &d3d11_desc, data)))
|
||||
{
|
||||
WARN("Failed to initialize texture, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
|
@ -199,7 +199,26 @@ static UINT STDMETHODCALLTYPE d3d11_texture2d_GetEvictionPriority(ID3D11Texture2
|
||||
|
||||
static void STDMETHODCALLTYPE d3d11_texture2d_GetDesc(ID3D11Texture2D *iface, D3D11_TEXTURE2D_DESC *desc)
|
||||
{
|
||||
FIXME("iface %p, desc %p stub!\n", iface, desc);
|
||||
struct d3d10_texture2d *texture = impl_from_ID3D11Texture2D(iface);
|
||||
struct wined3d_resource_desc wined3d_desc;
|
||||
|
||||
TRACE("iface %p, desc %p.\n", iface, desc);
|
||||
|
||||
*desc = texture->desc;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_resource_get_desc(wined3d_texture_get_resource(texture->wined3d_texture), &wined3d_desc);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
/* FIXME: Resizing swapchain buffers can cause these to change. We'd like
|
||||
* to get everything from wined3d, but e.g. bind flags don't exist as such
|
||||
* there (yet). */
|
||||
desc->Width = wined3d_desc.width;
|
||||
desc->Height = wined3d_desc.height;
|
||||
desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
|
||||
desc->SampleDesc.Count = wined3d_desc.multisample_type == WINED3D_MULTISAMPLE_NONE
|
||||
? 1 : wined3d_desc.multisample_type;
|
||||
desc->SampleDesc.Quality = wined3d_desc.multisample_quality;
|
||||
}
|
||||
|
||||
static const struct ID3D11Texture2DVtbl d3d11_texture2d_vtbl =
|
||||
@ -373,25 +392,22 @@ static void STDMETHODCALLTYPE d3d10_texture2d_Unmap(ID3D10Texture2D *iface, UINT
|
||||
static void STDMETHODCALLTYPE d3d10_texture2d_GetDesc(ID3D10Texture2D *iface, D3D10_TEXTURE2D_DESC *desc)
|
||||
{
|
||||
struct d3d10_texture2d *texture = impl_from_ID3D10Texture2D(iface);
|
||||
struct wined3d_resource_desc wined3d_desc;
|
||||
D3D11_TEXTURE2D_DESC d3d11_desc;
|
||||
|
||||
TRACE("iface %p, desc %p\n", iface, desc);
|
||||
|
||||
*desc = texture->desc;
|
||||
d3d11_texture2d_GetDesc(&texture->ID3D11Texture2D_iface, &d3d11_desc);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_resource_get_desc(wined3d_texture_get_resource(texture->wined3d_texture), &wined3d_desc);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
/* FIXME: Resizing swapchain buffers can cause these to change. We'd like
|
||||
* to get everything from wined3d, but e.g. bind flags don't exist as such
|
||||
* there (yet). */
|
||||
desc->Width = wined3d_desc.width;
|
||||
desc->Height = wined3d_desc.height;
|
||||
desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
|
||||
desc->SampleDesc.Count = wined3d_desc.multisample_type == WINED3D_MULTISAMPLE_NONE
|
||||
? 1 : wined3d_desc.multisample_type;
|
||||
desc->SampleDesc.Quality = wined3d_desc.multisample_quality;
|
||||
desc->Width = d3d11_desc.Width;
|
||||
desc->Height = d3d11_desc.Height;
|
||||
desc->MipLevels = d3d11_desc.MipLevels;
|
||||
desc->ArraySize = d3d11_desc.ArraySize;
|
||||
desc->Format = d3d11_desc.Format;
|
||||
desc->SampleDesc = d3d11_desc.SampleDesc;
|
||||
desc->Usage = d3d10_usage_from_d3d11_usage(d3d11_desc.Usage);
|
||||
desc->BindFlags = d3d10_bind_flags_from_d3d11_bind_flags(d3d11_desc.BindFlags);
|
||||
desc->CPUAccessFlags = d3d10_cpu_access_flags_from_d3d11_cpu_access_flags(d3d11_desc.CPUAccessFlags);
|
||||
desc->MiscFlags = d3d10_resource_misc_flags_from_d3d11_resource_misc_flags(d3d11_desc.MiscFlags);
|
||||
}
|
||||
|
||||
static const struct ID3D10Texture2DVtbl d3d10_texture2d_vtbl =
|
||||
@ -429,7 +445,7 @@ static const struct wined3d_parent_ops d3d10_texture2d_wined3d_parent_ops =
|
||||
};
|
||||
|
||||
HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device *device,
|
||||
const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data)
|
||||
const D3D11_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data)
|
||||
{
|
||||
struct wined3d_resource_desc wined3d_desc;
|
||||
unsigned int levels;
|
||||
|
@ -345,28 +345,173 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format)
|
||||
}
|
||||
}
|
||||
|
||||
DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage)
|
||||
DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage)
|
||||
{
|
||||
static const DWORD handled = D3D10_BIND_SHADER_RESOURCE
|
||||
| D3D10_BIND_RENDER_TARGET
|
||||
| D3D10_BIND_DEPTH_STENCIL;
|
||||
static const DWORD handled = D3D11_BIND_SHADER_RESOURCE
|
||||
| D3D11_BIND_RENDER_TARGET
|
||||
| D3D11_BIND_DEPTH_STENCIL;
|
||||
DWORD wined3d_usage = 0;
|
||||
|
||||
if (bind_flags & D3D10_BIND_SHADER_RESOURCE)
|
||||
if (bind_flags & D3D11_BIND_SHADER_RESOURCE)
|
||||
wined3d_usage |= WINED3DUSAGE_TEXTURE;
|
||||
if (bind_flags & D3D10_BIND_RENDER_TARGET)
|
||||
if (bind_flags & D3D11_BIND_RENDER_TARGET)
|
||||
wined3d_usage |= WINED3DUSAGE_RENDERTARGET;
|
||||
if (bind_flags & D3D10_BIND_DEPTH_STENCIL)
|
||||
if (bind_flags & D3D11_BIND_DEPTH_STENCIL)
|
||||
wined3d_usage |= WINED3DUSAGE_DEPTHSTENCIL;
|
||||
if (bind_flags & ~handled)
|
||||
FIXME("Unhandled bind flags %#x.\n", usage & ~handled);
|
||||
|
||||
if (usage == D3D10_USAGE_DYNAMIC)
|
||||
if (usage == D3D11_USAGE_DYNAMIC)
|
||||
wined3d_usage |= WINED3DUSAGE_DYNAMIC;
|
||||
|
||||
return wined3d_usage;
|
||||
}
|
||||
|
||||
DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage)
|
||||
{
|
||||
UINT d3d11_bind_flags = d3d11_bind_flags_from_d3d10_bind_flags(bind_flags);
|
||||
enum D3D11_USAGE d3d11_usage = d3d11_usage_from_d3d10_usage(usage);
|
||||
return wined3d_usage_from_d3d11(d3d11_bind_flags, d3d11_usage);
|
||||
}
|
||||
|
||||
enum D3D11_USAGE d3d11_usage_from_d3d10_usage(enum D3D10_USAGE usage)
|
||||
{
|
||||
switch (usage)
|
||||
{
|
||||
case D3D10_USAGE_DEFAULT: return D3D11_USAGE_DEFAULT;
|
||||
case D3D10_USAGE_IMMUTABLE: return D3D11_USAGE_IMMUTABLE;
|
||||
case D3D10_USAGE_DYNAMIC: return D3D11_USAGE_DYNAMIC;
|
||||
case D3D10_USAGE_STAGING: return D3D11_USAGE_STAGING;
|
||||
default:
|
||||
FIXME("Unhandled usage %#x.\n", usage);
|
||||
return D3D11_USAGE_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
enum D3D10_USAGE d3d10_usage_from_d3d11_usage(enum D3D11_USAGE usage)
|
||||
{
|
||||
switch (usage)
|
||||
{
|
||||
case D3D11_USAGE_DEFAULT: return D3D10_USAGE_DEFAULT;
|
||||
case D3D11_USAGE_IMMUTABLE: return D3D10_USAGE_IMMUTABLE;
|
||||
case D3D11_USAGE_DYNAMIC: return D3D10_USAGE_DYNAMIC;
|
||||
case D3D11_USAGE_STAGING: return D3D10_USAGE_STAGING;
|
||||
default:
|
||||
FIXME("Unhandled usage %#x.\n", usage);
|
||||
return D3D10_USAGE_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
UINT d3d11_bind_flags_from_d3d10_bind_flags(UINT bind_flags)
|
||||
{
|
||||
static const UINT handled_flags = D3D10_BIND_VERTEX_BUFFER
|
||||
| D3D10_BIND_INDEX_BUFFER
|
||||
| D3D10_BIND_CONSTANT_BUFFER
|
||||
| D3D10_BIND_SHADER_RESOURCE
|
||||
| D3D10_BIND_STREAM_OUTPUT
|
||||
| D3D10_BIND_RENDER_TARGET
|
||||
| D3D10_BIND_DEPTH_STENCIL;
|
||||
UINT d3d11_bind_flags = bind_flags & handled_flags;
|
||||
|
||||
if (bind_flags & ~handled_flags)
|
||||
FIXME("Unhandled bind flags %#x.\n", bind_flags & ~handled_flags);
|
||||
|
||||
return d3d11_bind_flags;
|
||||
}
|
||||
|
||||
UINT d3d10_bind_flags_from_d3d11_bind_flags(UINT bind_flags)
|
||||
{
|
||||
static const UINT handled_flags = D3D11_BIND_VERTEX_BUFFER
|
||||
| D3D11_BIND_INDEX_BUFFER
|
||||
| D3D11_BIND_CONSTANT_BUFFER
|
||||
| D3D11_BIND_SHADER_RESOURCE
|
||||
| D3D11_BIND_STREAM_OUTPUT
|
||||
| D3D11_BIND_RENDER_TARGET
|
||||
| D3D11_BIND_DEPTH_STENCIL
|
||||
| D3D11_BIND_UNORDERED_ACCESS
|
||||
| D3D11_BIND_DECODER
|
||||
| D3D11_BIND_VIDEO_ENCODER;
|
||||
UINT d3d10_bind_flags = bind_flags & handled_flags;
|
||||
|
||||
if (bind_flags & ~handled_flags)
|
||||
FIXME("Unhandled bind flags %#x.\n", bind_flags & ~handled_flags);
|
||||
|
||||
return d3d10_bind_flags;
|
||||
}
|
||||
|
||||
UINT d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(UINT cpu_access_flags)
|
||||
{
|
||||
static const UINT handled_flags = D3D10_CPU_ACCESS_WRITE
|
||||
| D3D10_CPU_ACCESS_READ;
|
||||
UINT d3d11_cpu_access_flags = cpu_access_flags & handled_flags;
|
||||
|
||||
if (cpu_access_flags & ~handled_flags)
|
||||
FIXME("Unhandled cpu access flags %#x.\n", cpu_access_flags & ~handled_flags);
|
||||
|
||||
return d3d11_cpu_access_flags;
|
||||
}
|
||||
|
||||
UINT d3d10_cpu_access_flags_from_d3d11_cpu_access_flags(UINT cpu_access_flags)
|
||||
{
|
||||
static const UINT handled_flags = D3D11_CPU_ACCESS_WRITE
|
||||
| D3D11_CPU_ACCESS_READ;
|
||||
UINT d3d10_cpu_access_flags = cpu_access_flags & handled_flags;
|
||||
|
||||
if (cpu_access_flags & ~handled_flags)
|
||||
FIXME("Unhandled cpu access flags %#x.\n", cpu_access_flags & ~handled_flags);
|
||||
|
||||
return d3d10_cpu_access_flags;
|
||||
}
|
||||
|
||||
UINT d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(UINT resource_misc_flags)
|
||||
{
|
||||
static const UINT bitwise_identical_flags = D3D10_RESOURCE_MISC_GENERATE_MIPS
|
||||
| D3D10_RESOURCE_MISC_SHARED
|
||||
| D3D10_RESOURCE_MISC_TEXTURECUBE;
|
||||
static const UINT handled_flags = bitwise_identical_flags
|
||||
| D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX
|
||||
| D3D10_RESOURCE_MISC_GDI_COMPATIBLE;
|
||||
UINT d3d11_resource_misc_flags = resource_misc_flags & bitwise_identical_flags;
|
||||
|
||||
if (resource_misc_flags & D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX)
|
||||
d3d11_resource_misc_flags |= D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
|
||||
if (resource_misc_flags & D3D10_RESOURCE_MISC_GDI_COMPATIBLE)
|
||||
d3d11_resource_misc_flags |= D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
|
||||
|
||||
if (resource_misc_flags & ~handled_flags)
|
||||
FIXME("Unhandled resource misc flags %#x.\n", resource_misc_flags & ~handled_flags);
|
||||
|
||||
return d3d11_resource_misc_flags;
|
||||
}
|
||||
|
||||
UINT d3d10_resource_misc_flags_from_d3d11_resource_misc_flags(UINT resource_misc_flags)
|
||||
{
|
||||
static const UINT bitwise_identical_flags = D3D11_RESOURCE_MISC_GENERATE_MIPS
|
||||
| D3D11_RESOURCE_MISC_SHARED
|
||||
| D3D11_RESOURCE_MISC_TEXTURECUBE
|
||||
| D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
|
||||
| D3D11_RESOURCE_MISC_RESOURCE_CLAMP
|
||||
| D3D11_RESOURCE_MISC_SHARED_NTHANDLE
|
||||
| D3D11_RESOURCE_MISC_RESTRICTED_CONTENT
|
||||
| D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE
|
||||
| D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE_DRIVER
|
||||
| D3D11_RESOURCE_MISC_GUARDED;
|
||||
static const UINT handled_flags = bitwise_identical_flags
|
||||
| D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
|
||||
| D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
|
||||
UINT d3d10_resource_misc_flags = resource_misc_flags & bitwise_identical_flags;
|
||||
|
||||
if (resource_misc_flags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX)
|
||||
d3d10_resource_misc_flags |= D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX;
|
||||
if (resource_misc_flags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE)
|
||||
d3d10_resource_misc_flags |= D3D10_RESOURCE_MISC_GDI_COMPATIBLE;
|
||||
|
||||
if (resource_misc_flags & ~handled_flags)
|
||||
FIXME("Unhandled resource misc flags #%x.\n", resource_misc_flags & ~handled_flags);
|
||||
|
||||
return d3d10_resource_misc_flags;
|
||||
}
|
||||
|
||||
struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource)
|
||||
{
|
||||
D3D10_RESOURCE_DIMENSION dimension;
|
||||
|
Loading…
Reference in New Issue
Block a user