2009-01-23 10:22:34 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2009-10-29 18:56:23 +01:00
|
|
|
#define NONAMELESSUNION
|
2015-08-21 00:07:53 +02:00
|
|
|
#include "d3d11_private.h"
|
2009-01-23 10:22:34 +01:00
|
|
|
|
2015-08-21 00:07:53 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
static HRESULT set_dsdesc_from_resource(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resource *resource)
|
2012-09-13 09:18:14 +02:00
|
|
|
{
|
2015-09-08 01:12:45 +02:00
|
|
|
D3D11_RESOURCE_DIMENSION dimension;
|
2012-09-13 09:18:14 +02:00
|
|
|
|
2015-09-08 01:12:45 +02:00
|
|
|
ID3D11Resource_GetType(resource, &dimension);
|
2012-09-13 09:18:14 +02:00
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->Flags = 0;
|
|
|
|
|
2012-09-13 09:18:14 +02:00
|
|
|
switch (dimension)
|
|
|
|
{
|
2015-09-08 01:12:45 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
2012-09-13 09:18:14 +02:00
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
D3D11_TEXTURE1D_DESC texture_desc;
|
|
|
|
ID3D11Texture1D *texture;
|
2012-09-13 09:18:14 +02:00
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
|
2012-09-13 09:18:14 +02:00
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
|
2012-09-13 09:18:14 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
ID3D11Texture1D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture1D_Release(texture);
|
2012-09-13 09:18:14 +02:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
if (texture_desc.ArraySize == 1)
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->ViewDimension = D3D11_DSV_DIMENSION_TEXTURE1D;
|
2012-09-13 09:18:14 +02:00
|
|
|
desc->u.Texture1D.MipSlice = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->ViewDimension = D3D11_DSV_DIMENSION_TEXTURE1DARRAY;
|
2012-09-13 09:18:14 +02:00
|
|
|
desc->u.Texture1DArray.MipSlice = 0;
|
|
|
|
desc->u.Texture1DArray.FirstArraySlice = 0;
|
2016-05-13 13:55:31 +02:00
|
|
|
desc->u.Texture1DArray.ArraySize = texture_desc.ArraySize;
|
2012-09-13 09:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:45 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
2012-09-13 09:18:14 +02:00
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
D3D11_TEXTURE2D_DESC texture_desc;
|
|
|
|
ID3D11Texture2D *texture;
|
2012-09-13 09:18:14 +02:00
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
|
2012-09-13 09:18:14 +02:00
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
|
2012-09-13 09:18:14 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
ID3D11Texture2D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture2D_Release(texture);
|
2012-09-13 09:18:14 +02:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
if (texture_desc.ArraySize == 1)
|
|
|
|
{
|
|
|
|
if (texture_desc.SampleDesc.Count == 1)
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
2012-09-13 09:18:14 +02:00
|
|
|
desc->u.Texture2D.MipSlice = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
|
2012-09-13 09:18:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (texture_desc.SampleDesc.Count == 1)
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
2012-09-13 09:18:14 +02:00
|
|
|
desc->u.Texture2DArray.MipSlice = 0;
|
|
|
|
desc->u.Texture2DArray.FirstArraySlice = 0;
|
2016-05-13 13:55:31 +02:00
|
|
|
desc->u.Texture2DArray.ArraySize = texture_desc.ArraySize;
|
2012-09-13 09:18:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
|
2012-09-13 09:18:14 +02:00
|
|
|
desc->u.Texture2DMSArray.FirstArraySlice = 0;
|
2016-05-13 13:55:31 +02:00
|
|
|
desc->u.Texture2DMSArray.ArraySize = texture_desc.ArraySize;
|
2012-09-13 09:18:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled resource dimension %#x.\n", dimension);
|
2015-09-08 01:12:45 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_BUFFER:
|
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
2012-09-13 09:18:14 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-18 00:04:38 +02:00
|
|
|
static void normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resource *resource)
|
|
|
|
{
|
|
|
|
D3D11_RESOURCE_DIMENSION dimension;
|
|
|
|
|
|
|
|
if (desc->Format != DXGI_FORMAT_UNKNOWN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ID3D11Resource_GetType(resource, &dimension);
|
|
|
|
switch (dimension)
|
|
|
|
{
|
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
|
|
|
{
|
|
|
|
D3D11_TEXTURE1D_DESC texture_desc;
|
|
|
|
ID3D11Texture1D *texture;
|
|
|
|
|
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
|
|
|
|
{
|
|
|
|
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ID3D11Texture1D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture1D_Release(texture);
|
|
|
|
|
|
|
|
if (desc->Format == DXGI_FORMAT_UNKNOWN)
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
|
|
|
{
|
|
|
|
D3D11_TEXTURE2D_DESC texture_desc;
|
|
|
|
ID3D11Texture2D *texture;
|
|
|
|
|
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
|
|
|
|
{
|
|
|
|
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ID3D11Texture2D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture2D_Release(texture);
|
|
|
|
|
|
|
|
if (desc->Format == DXGI_FORMAT_UNKNOWN)
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2015-09-09 01:35:43 +02:00
|
|
|
D3D11_RESOURCE_DIMENSION dimension;
|
2009-10-29 18:56:23 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-09-09 01:35:43 +02:00
|
|
|
ID3D11Resource_GetType(resource, &dimension);
|
2009-10-29 18:56:23 +01:00
|
|
|
|
|
|
|
switch(dimension)
|
|
|
|
{
|
2015-09-09 01:35:43 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Texture1D *texture;
|
|
|
|
D3D11_TEXTURE1D_DESC texture_desc;
|
2009-10-29 18:56:23 +01:00
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture);
|
2009-10-29 18:56:23 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D?\n");
|
2009-10-29 18:56:23 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Texture1D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture1D_Release(texture);
|
2009-10-29 18:56:23 +01:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
if (texture_desc.ArraySize == 1)
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D;
|
2009-10-29 18:56:23 +01:00
|
|
|
desc->u.Texture1D.MipSlice = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1DARRAY;
|
2009-10-29 18:56:23 +01:00
|
|
|
desc->u.Texture1DArray.MipSlice = 0;
|
|
|
|
desc->u.Texture1DArray.FirstArraySlice = 0;
|
2016-05-13 13:55:31 +02:00
|
|
|
desc->u.Texture1DArray.ArraySize = texture_desc.ArraySize;
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:43 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Texture2D *texture;
|
|
|
|
D3D11_TEXTURE2D_DESC texture_desc;
|
2009-10-29 18:56:23 +01:00
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture);
|
2009-10-29 18:56:23 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D?\n");
|
2009-10-29 18:56:23 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Texture2D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture2D_Release(texture);
|
2009-10-29 18:56:23 +01:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
if (texture_desc.ArraySize == 1)
|
|
|
|
{
|
|
|
|
if (texture_desc.SampleDesc.Count == 1)
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
2009-10-29 18:56:23 +01:00
|
|
|
desc->u.Texture2D.MipSlice = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (texture_desc.SampleDesc.Count == 1)
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
2009-10-29 18:56:23 +01:00
|
|
|
desc->u.Texture2DArray.MipSlice = 0;
|
|
|
|
desc->u.Texture2DArray.FirstArraySlice = 0;
|
2016-05-13 13:55:31 +02:00
|
|
|
desc->u.Texture2DArray.ArraySize = texture_desc.ArraySize;
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
2009-10-29 18:56:23 +01:00
|
|
|
desc->u.Texture2DMSArray.FirstArraySlice = 0;
|
2016-05-13 13:55:31 +02:00
|
|
|
desc->u.Texture2DMSArray.ArraySize = texture_desc.ArraySize;
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:43 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Texture3D *texture;
|
|
|
|
D3D11_TEXTURE3D_DESC texture_desc;
|
2009-10-29 18:56:23 +01:00
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture3D, (void **)&texture);
|
2009-10-29 18:56:23 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
ERR("Resource of type TEXTURE3D doesn't implement ID3D11Texture3D?\n");
|
2009-10-29 18:56:23 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Texture3D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture3D_Release(texture);
|
2009-10-29 18:56:23 +01:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
2015-09-09 01:35:44 +02:00
|
|
|
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
|
2009-10-29 18:56:23 +01:00
|
|
|
desc->u.Texture3D.MipSlice = 0;
|
|
|
|
desc->u.Texture3D.FirstWSlice = 0;
|
2016-06-08 14:54:57 +02:00
|
|
|
desc->u.Texture3D.WSize = texture_desc.Depth;
|
2009-10-29 18:56:23 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled resource dimension %#x.\n", dimension);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-18 00:04:38 +02:00
|
|
|
static void normalize_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
|
|
|
|
{
|
|
|
|
D3D11_RESOURCE_DIMENSION dimension;
|
2016-06-08 14:54:57 +02:00
|
|
|
unsigned int layer_count;
|
|
|
|
DXGI_FORMAT format;
|
2016-05-18 00:04:38 +02:00
|
|
|
|
|
|
|
ID3D11Resource_GetType(resource, &dimension);
|
|
|
|
switch (dimension)
|
|
|
|
{
|
2016-06-08 14:54:57 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-08 14:54:57 +02:00
|
|
|
const struct d3d_texture2d *texture;
|
2016-05-18 00:04:38 +02:00
|
|
|
|
2016-06-08 14:54:57 +02:00
|
|
|
if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource)))
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-08 14:54:57 +02:00
|
|
|
ERR("Cannot get implementation from ID3D11Texture2D.\n");
|
|
|
|
return;
|
2016-05-18 00:04:38 +02:00
|
|
|
}
|
|
|
|
|
2016-06-08 14:54:57 +02:00
|
|
|
format = texture->desc.Format;
|
|
|
|
layer_count = texture->desc.ArraySize;
|
2016-05-18 00:04:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-08 14:54:57 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-08 14:54:57 +02:00
|
|
|
const struct d3d_texture3d *texture;
|
2016-05-18 00:04:38 +02:00
|
|
|
|
2016-06-08 14:54:57 +02:00
|
|
|
if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource)))
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-08 14:54:57 +02:00
|
|
|
ERR("Cannot get implementation from ID3D11Texture3D.\n");
|
|
|
|
return;
|
2016-05-18 00:04:38 +02:00
|
|
|
}
|
|
|
|
|
2016-06-08 14:54:57 +02:00
|
|
|
format = texture->desc.Format;
|
|
|
|
layer_count = texture->desc.Depth;
|
2016-05-18 00:04:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-08 14:54:57 +02:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desc->Format == DXGI_FORMAT_UNKNOWN)
|
|
|
|
desc->Format = format;
|
|
|
|
|
|
|
|
switch (desc->ViewDimension)
|
|
|
|
{
|
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
|
|
|
|
if (desc->u.Texture1DArray.ArraySize == -1 && desc->u.Texture1DArray.FirstArraySlice < layer_count)
|
|
|
|
desc->u.Texture1DArray.ArraySize = layer_count - desc->u.Texture1DArray.ArraySize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
|
|
|
|
if (desc->u.Texture2DArray.ArraySize == -1 && desc->u.Texture2DArray.FirstArraySlice < layer_count)
|
|
|
|
desc->u.Texture2DArray.ArraySize = layer_count - desc->u.Texture2DArray.FirstArraySlice;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
|
|
|
|
if (desc->u.Texture2DMSArray.ArraySize == -1 && desc->u.Texture2DMSArray.FirstArraySlice < layer_count)
|
|
|
|
desc->u.Texture2DMSArray.ArraySize = layer_count - desc->u.Texture2DMSArray.FirstArraySlice;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE3D:
|
|
|
|
layer_count = max(1, layer_count >> desc->u.Texture3D.MipSlice);
|
|
|
|
if (desc->u.Texture3D.WSize == -1 && desc->u.Texture3D.FirstWSlice < layer_count)
|
|
|
|
desc->u.Texture3D.WSize = layer_count - desc->u.Texture3D.FirstWSlice;
|
|
|
|
break;
|
|
|
|
|
2016-05-18 00:04:38 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11Resource *resource)
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
D3D11_RESOURCE_DIMENSION dimension;
|
2012-09-14 13:11:31 +02:00
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Resource_GetType(resource, &dimension);
|
2012-09-14 13:11:31 +02:00
|
|
|
|
|
|
|
switch (dimension)
|
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
D3D11_TEXTURE1D_DESC texture_desc;
|
|
|
|
ID3D11Texture1D *texture;
|
2012-09-14 13:11:31 +02:00
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
|
2012-09-14 13:11:31 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Texture1D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture1D_Release(texture);
|
2012-09-14 13:11:31 +02:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
if (texture_desc.ArraySize == 1)
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
|
2012-09-14 13:11:31 +02:00
|
|
|
desc->u.Texture1D.MostDetailedMip = 0;
|
|
|
|
desc->u.Texture1D.MipLevels = texture_desc.MipLevels;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
|
2012-09-14 13:11:31 +02:00
|
|
|
desc->u.Texture1DArray.MostDetailedMip = 0;
|
|
|
|
desc->u.Texture1DArray.MipLevels = texture_desc.MipLevels;
|
|
|
|
desc->u.Texture1DArray.FirstArraySlice = 0;
|
|
|
|
desc->u.Texture1DArray.ArraySize = texture_desc.ArraySize;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
D3D11_TEXTURE2D_DESC texture_desc;
|
|
|
|
ID3D11Texture2D *texture;
|
2012-09-14 13:11:31 +02:00
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
|
2012-09-14 13:11:31 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Texture2D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture2D_Release(texture);
|
2012-09-14 13:11:31 +02:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
|
|
|
if (texture_desc.ArraySize == 1)
|
|
|
|
{
|
|
|
|
if (texture_desc.SampleDesc.Count == 1)
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
2012-09-14 13:11:31 +02:00
|
|
|
desc->u.Texture2D.MostDetailedMip = 0;
|
|
|
|
desc->u.Texture2D.MipLevels = texture_desc.MipLevels;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
|
2012-09-14 13:11:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (texture_desc.SampleDesc.Count == 1)
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
|
2012-09-14 13:11:31 +02:00
|
|
|
desc->u.Texture2DArray.MostDetailedMip = 0;
|
|
|
|
desc->u.Texture2DArray.MipLevels = texture_desc.MipLevels;
|
|
|
|
desc->u.Texture2DArray.FirstArraySlice = 0;
|
|
|
|
desc->u.Texture2DArray.ArraySize = texture_desc.ArraySize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY;
|
2012-09-14 13:11:31 +02:00
|
|
|
desc->u.Texture2DMSArray.FirstArraySlice = 0;
|
|
|
|
desc->u.Texture2DMSArray.ArraySize = texture_desc.ArraySize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
D3D11_TEXTURE3D_DESC texture_desc;
|
|
|
|
ID3D11Texture3D *texture;
|
2012-09-14 13:11:31 +02:00
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture3D, (void **)&texture)))
|
2012-09-14 13:11:31 +02:00
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
ERR("Resource of type TEXTURE3D doesn't implement ID3D11Texture3D.\n");
|
2012-09-14 13:11:31 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Texture3D_GetDesc(texture, &texture_desc);
|
|
|
|
ID3D11Texture3D_Release(texture);
|
2012-09-14 13:11:31 +02:00
|
|
|
|
|
|
|
desc->Format = texture_desc.Format;
|
2015-09-10 00:55:45 +02:00
|
|
|
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
|
2012-09-14 13:11:31 +02:00
|
|
|
desc->u.Texture3D.MostDetailedMip = 0;
|
|
|
|
desc->u.Texture3D.MipLevels = texture_desc.MipLevels;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled resource dimension %#x.\n", dimension);
|
2015-09-10 00:55:46 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_BUFFER:
|
2012-09-14 13:11:31 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-18 00:04:38 +02:00
|
|
|
static void normalize_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11Resource *resource)
|
|
|
|
{
|
2016-06-06 11:39:03 +02:00
|
|
|
unsigned int miplevel_count, layer_count;
|
2016-05-18 00:04:38 +02:00
|
|
|
D3D11_RESOURCE_DIMENSION dimension;
|
2016-06-06 11:39:03 +02:00
|
|
|
DXGI_FORMAT format;
|
2016-05-18 00:04:38 +02:00
|
|
|
|
|
|
|
ID3D11Resource_GetType(resource, &dimension);
|
|
|
|
switch (dimension)
|
|
|
|
{
|
2016-06-06 11:39:03 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-06 11:39:03 +02:00
|
|
|
const struct d3d_texture2d *texture;
|
2016-05-18 00:04:38 +02:00
|
|
|
|
2016-06-06 11:39:03 +02:00
|
|
|
if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource)))
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-06 11:39:03 +02:00
|
|
|
ERR("Cannot get implementation from ID3D11Texture2D.\n");
|
|
|
|
return;
|
2016-05-18 00:04:38 +02:00
|
|
|
}
|
|
|
|
|
2016-06-06 11:39:03 +02:00
|
|
|
format = texture->desc.Format;
|
|
|
|
miplevel_count = texture->desc.MipLevels;
|
|
|
|
layer_count = texture->desc.ArraySize;
|
2016-05-18 00:04:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-06 11:39:03 +02:00
|
|
|
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-06 11:39:03 +02:00
|
|
|
const struct d3d_texture3d *texture;
|
2016-05-18 00:04:38 +02:00
|
|
|
|
2016-06-06 11:39:03 +02:00
|
|
|
if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource)))
|
2016-05-18 00:04:38 +02:00
|
|
|
{
|
2016-06-06 11:39:03 +02:00
|
|
|
ERR("Cannot get implementation from ID3D11Texture3D.\n");
|
|
|
|
return;
|
2016-05-18 00:04:38 +02:00
|
|
|
}
|
|
|
|
|
2016-06-06 11:39:03 +02:00
|
|
|
format = texture->desc.Format;
|
|
|
|
miplevel_count = texture->desc.MipLevels;
|
|
|
|
layer_count = 1;
|
2016-05-18 00:04:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-06 11:39:03 +02:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desc->Format == DXGI_FORMAT_UNKNOWN)
|
|
|
|
desc->Format = format;
|
|
|
|
|
|
|
|
switch (desc->ViewDimension)
|
|
|
|
{
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE1D:
|
|
|
|
if (desc->u.Texture1D.MipLevels == -1 && desc->u.Texture1D.MostDetailedMip < miplevel_count)
|
|
|
|
desc->u.Texture1D.MipLevels = miplevel_count - desc->u.Texture1D.MostDetailedMip;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE2D:
|
|
|
|
if (desc->u.Texture2D.MipLevels == -1 && desc->u.Texture2D.MostDetailedMip < miplevel_count)
|
|
|
|
desc->u.Texture2D.MipLevels = miplevel_count - desc->u.Texture2D.MostDetailedMip;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE2DARRAY:
|
|
|
|
if (desc->u.Texture2DArray.MipLevels == -1 && desc->u.Texture2DArray.MostDetailedMip < miplevel_count)
|
|
|
|
desc->u.Texture2DArray.MipLevels = miplevel_count - desc->u.Texture2DArray.MostDetailedMip;
|
|
|
|
if (desc->u.Texture2DArray.ArraySize == -1 && desc->u.Texture2DArray.FirstArraySlice < layer_count)
|
|
|
|
desc->u.Texture2DArray.ArraySize = layer_count - desc->u.Texture2DArray.FirstArraySlice;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE3D:
|
|
|
|
if (desc->u.Texture3D.MipLevels == -1 && desc->u.Texture3D.MostDetailedMip < miplevel_count)
|
|
|
|
desc->u.Texture3D.MipLevels = miplevel_count - desc->u.Texture3D.MostDetailedMip;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURECUBE:
|
|
|
|
if (desc->u.TextureCube.MipLevels == -1 && desc->u.TextureCube.MostDetailedMip < miplevel_count)
|
|
|
|
desc->u.TextureCube.MipLevels = miplevel_count - desc->u.TextureCube.MostDetailedMip;
|
|
|
|
break;
|
|
|
|
|
2016-05-18 00:04:38 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
/* ID3D11DepthStencilView methods */
|
|
|
|
|
|
|
|
static inline struct d3d_depthstencil_view *impl_from_ID3D11DepthStencilView(ID3D11DepthStencilView *iface)
|
2011-06-01 10:37:49 +02:00
|
|
|
{
|
2015-09-08 01:12:42 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_depthstencil_view, ID3D11DepthStencilView_iface);
|
2011-06-01 10:37:49 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_depthstencil_view_QueryInterface(ID3D11DepthStencilView *iface,
|
2009-10-30 20:11:32 +01:00
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
2015-09-08 01:12:42 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
2009-10-30 20:11:32 +01:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D11DepthStencilView)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11View)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|
2009-10-30 20:11:32 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2015-09-08 01:12:42 +02:00
|
|
|
ID3D11DepthStencilView_AddRef(iface);
|
2009-10-30 20:11:32 +01:00
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D10DepthStencilView)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10View)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
|
|
|
|
{
|
|
|
|
ID3D10DepthStencilView_AddRef(&view->ID3D10DepthStencilView_iface);
|
|
|
|
*object = &view->ID3D10DepthStencilView_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-30 20:11:32 +01:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_depthstencil_view_AddRef(ID3D11DepthStencilView *iface)
|
2009-10-30 20:11:32 +01:00
|
|
|
{
|
2015-09-08 01:12:42 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&view->refcount);
|
2009-10-30 20:11:32 +01:00
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", view, refcount);
|
2009-10-30 20:11:32 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_depthstencil_view_Release(ID3D11DepthStencilView *iface)
|
2009-10-30 20:11:32 +01:00
|
|
|
{
|
2015-09-08 01:12:42 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&view->refcount);
|
2009-10-30 20:11:32 +01:00
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", view, refcount);
|
2009-10-30 20:11:32 +01:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-08 01:12:42 +02:00
|
|
|
wined3d_rendertarget_view_decref(view->wined3d_view);
|
2015-09-08 01:12:45 +02:00
|
|
|
ID3D11Resource_Release(view->resource);
|
2015-09-08 01:12:43 +02:00
|
|
|
ID3D11Device_Release(view->device);
|
2015-09-08 01:12:42 +02:00
|
|
|
wined3d_private_store_cleanup(&view->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2015-09-08 01:12:42 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, view);
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d11_depthstencil_view_GetDevice(ID3D11DepthStencilView *iface,
|
|
|
|
ID3D11Device **device)
|
|
|
|
{
|
2015-09-08 01:12:43 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
|
|
|
*device = view->device;
|
|
|
|
ID3D11Device_AddRef(*device);
|
2015-09-08 01:12:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_depthstencil_view_GetPrivateData(ID3D11DepthStencilView *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return d3d_get_private_data(&view->private_store, guid, data_size, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_depthstencil_view_SetPrivateData(ID3D11DepthStencilView *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return d3d_set_private_data(&view->private_store, guid, data_size, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_depthstencil_view_SetPrivateDataInterface(ID3D11DepthStencilView *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
|
|
|
return d3d_set_private_data_interface(&view->private_store, guid, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d11_depthstencil_view_GetResource(ID3D11DepthStencilView *iface,
|
|
|
|
ID3D11Resource **resource)
|
|
|
|
{
|
2015-09-08 01:12:45 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, resource %p.\n", iface, resource);
|
|
|
|
|
|
|
|
*resource = view->resource;
|
|
|
|
ID3D11Resource_AddRef(*resource);
|
2015-09-08 01:12:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d11_depthstencil_view_GetDesc(ID3D11DepthStencilView *iface,
|
|
|
|
D3D11_DEPTH_STENCIL_VIEW_DESC *desc)
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
|
|
|
*desc = view->desc;
|
2015-09-08 01:12:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID3D11DepthStencilViewVtbl d3d11_depthstencil_view_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d11_depthstencil_view_QueryInterface,
|
|
|
|
d3d11_depthstencil_view_AddRef,
|
|
|
|
d3d11_depthstencil_view_Release,
|
|
|
|
/* ID3D11DeviceChild methods */
|
|
|
|
d3d11_depthstencil_view_GetDevice,
|
|
|
|
d3d11_depthstencil_view_GetPrivateData,
|
|
|
|
d3d11_depthstencil_view_SetPrivateData,
|
|
|
|
d3d11_depthstencil_view_SetPrivateDataInterface,
|
|
|
|
/* ID3D11View methods */
|
|
|
|
d3d11_depthstencil_view_GetResource,
|
|
|
|
/* ID3D11DepthStencilView methods */
|
|
|
|
d3d11_depthstencil_view_GetDesc,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ID3D10DepthStencilView methods */
|
|
|
|
|
|
|
|
static inline struct d3d_depthstencil_view *impl_from_ID3D10DepthStencilView(ID3D10DepthStencilView *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d3d_depthstencil_view, ID3D10DepthStencilView_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_QueryInterface(ID3D10DepthStencilView *iface,
|
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return d3d11_depthstencil_view_QueryInterface(&view->ID3D11DepthStencilView_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_depthstencil_view_AddRef(ID3D10DepthStencilView *iface)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_depthstencil_view_AddRef(&view->ID3D11DepthStencilView_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_depthstencil_view_Release(ID3D10DepthStencilView *iface)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_depthstencil_view_Release(&view->ID3D11DepthStencilView_iface);
|
|
|
|
}
|
|
|
|
|
2009-10-30 20:11:32 +01:00
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetDevice(ID3D10DepthStencilView *iface, ID3D10Device **device)
|
|
|
|
{
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
2014-02-13 10:14:22 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
2015-09-08 01:12:43 +02:00
|
|
|
ID3D11Device_QueryInterface(view->device, &IID_ID3D10Device, (void **)device);
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_GetPrivateData(ID3D10DepthStencilView *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
2015-03-12 10:08:33 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n",
|
2009-10-30 20:11:32 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_get_private_data(&view->private_store, guid, data_size, data);
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_SetPrivateData(ID3D10DepthStencilView *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
2015-03-11 11:13:54 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
|
2009-10-30 20:11:32 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data(&view->private_store, guid, data_size, data);
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_SetPrivateDataInterface(ID3D10DepthStencilView *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
2009-10-30 20:11:32 +01:00
|
|
|
|
2015-03-12 10:08:32 +01:00
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data_interface(&view->private_store, guid, data);
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10View methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetResource(ID3D10DepthStencilView *iface,
|
|
|
|
ID3D10Resource **resource)
|
|
|
|
{
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
2012-09-11 00:27:01 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, resource %p.\n", iface, resource);
|
|
|
|
|
2015-09-08 01:12:45 +02:00
|
|
|
ID3D11Resource_QueryInterface(view->resource, &IID_ID3D10Resource, (void **)resource);
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10DepthStencilView methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetDesc(ID3D10DepthStencilView *iface,
|
|
|
|
D3D10_DEPTH_STENCIL_VIEW_DESC *desc)
|
|
|
|
{
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *view = impl_from_ID3D10DepthStencilView(iface);
|
2015-09-08 01:12:46 +02:00
|
|
|
const D3D11_DEPTH_STENCIL_VIEW_DESC *d3d11_desc = &view->desc;
|
2012-09-13 09:18:14 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
desc->Format = d3d11_desc->Format;
|
|
|
|
desc->ViewDimension = (D3D10_DSV_DIMENSION)d3d11_desc->ViewDimension;
|
|
|
|
memcpy(&desc->u, &d3d11_desc->u, sizeof(desc->u));
|
2009-10-30 20:11:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID3D10DepthStencilViewVtbl d3d10_depthstencil_view_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d10_depthstencil_view_QueryInterface,
|
|
|
|
d3d10_depthstencil_view_AddRef,
|
|
|
|
d3d10_depthstencil_view_Release,
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
d3d10_depthstencil_view_GetDevice,
|
|
|
|
d3d10_depthstencil_view_GetPrivateData,
|
|
|
|
d3d10_depthstencil_view_SetPrivateData,
|
|
|
|
d3d10_depthstencil_view_SetPrivateDataInterface,
|
|
|
|
/* ID3D10View methods */
|
|
|
|
d3d10_depthstencil_view_GetResource,
|
|
|
|
/* ID3D10DepthStencilView methods */
|
|
|
|
d3d10_depthstencil_view_GetDesc,
|
|
|
|
};
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
static void wined3d_depth_stencil_view_desc_from_d3d11(struct wined3d_rendertarget_view_desc *wined3d_desc,
|
|
|
|
const D3D11_DEPTH_STENCIL_VIEW_DESC *desc)
|
2014-08-22 12:32:03 +02:00
|
|
|
{
|
|
|
|
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
if (desc->Flags)
|
|
|
|
FIXME("Unhandled depth stencil view flags %#x.\n", desc->Flags);
|
|
|
|
|
2014-08-22 12:32:03 +02:00
|
|
|
switch (desc->ViewDimension)
|
|
|
|
{
|
2015-09-08 01:12:46 +02:00
|
|
|
case D3D11_DSV_DIMENSION_TEXTURE1D:
|
2014-08-22 12:32:03 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture1D.MipSlice;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
case D3D11_DSV_DIMENSION_TEXTURE1DARRAY:
|
2014-08-22 12:32:03 +02:00
|
|
|
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;
|
|
|
|
break;
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
case D3D11_DSV_DIMENSION_TEXTURE2D:
|
2014-08-22 12:32:03 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture2D.MipSlice;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
case D3D11_DSV_DIMENSION_TEXTURE2DARRAY:
|
2014-08-22 12:32:03 +02:00
|
|
|
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;
|
|
|
|
break;
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
case D3D11_DSV_DIMENSION_TEXTURE2DMS:
|
2014-08-22 12:32:03 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY:
|
2014-08-22 12:32:03 +02:00
|
|
|
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;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
|
|
|
|
wined3d_desc->u.texture.level_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:47 +02:00
|
|
|
static HRESULT d3d_depthstencil_view_init(struct d3d_depthstencil_view *view, struct d3d_device *device,
|
2015-09-08 01:12:46 +02:00
|
|
|
ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc)
|
2009-10-30 20:11:32 +01:00
|
|
|
{
|
2014-08-22 12:32:03 +02:00
|
|
|
struct wined3d_rendertarget_view_desc wined3d_desc;
|
|
|
|
struct wined3d_resource *wined3d_resource;
|
2012-09-13 09:18:14 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-09-08 01:12:42 +02:00
|
|
|
view->ID3D11DepthStencilView_iface.lpVtbl = &d3d11_depthstencil_view_vtbl;
|
2011-06-01 10:37:49 +02:00
|
|
|
view->ID3D10DepthStencilView_iface.lpVtbl = &d3d10_depthstencil_view_vtbl;
|
2009-10-30 20:11:32 +01:00
|
|
|
view->refcount = 1;
|
|
|
|
|
2012-09-13 09:18:14 +02:00
|
|
|
if (!desc)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = set_dsdesc_from_resource(&view->desc, resource)))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
view->desc = *desc;
|
2016-05-18 00:04:38 +02:00
|
|
|
normalize_dsv_desc(&view->desc, resource);
|
2012-09-13 09:18:14 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-08 01:12:45 +02:00
|
|
|
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
|
2014-08-22 12:32:03 +02:00
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2015-09-08 01:12:45 +02:00
|
|
|
ERR("Failed to get wined3d resource for d3d11 resource %p.\n", resource);
|
2014-08-22 12:32:03 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:46 +02:00
|
|
|
wined3d_depth_stencil_view_desc_from_d3d11(&wined3d_desc, &view->desc);
|
2014-08-22 12:32:03 +02:00
|
|
|
if (FAILED(hr = wined3d_rendertarget_view_create(&wined3d_desc, wined3d_resource,
|
2015-10-09 03:19:12 +02:00
|
|
|
view, &d3d_null_wined3d_parent_ops, &view->wined3d_view)))
|
2014-08-22 12:32:03 +02:00
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-08-22 12:32:03 +02:00
|
|
|
WARN("Failed to create a wined3d rendertarget view, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-03-11 11:13:54 +01:00
|
|
|
wined3d_private_store_init(&view->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2012-09-11 00:27:01 +02:00
|
|
|
view->resource = resource;
|
2015-09-08 01:12:45 +02:00
|
|
|
ID3D11Resource_AddRef(resource);
|
2015-09-08 01:12:43 +02:00
|
|
|
view->device = &device->ID3D11Device_iface;
|
|
|
|
ID3D11Device_AddRef(view->device);
|
2012-09-11 00:27:01 +02:00
|
|
|
|
2009-10-30 20:11:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:47 +02:00
|
|
|
HRESULT d3d_depthstencil_view_create(struct d3d_device *device, ID3D11Resource *resource,
|
|
|
|
const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, struct d3d_depthstencil_view **view)
|
|
|
|
{
|
|
|
|
struct d3d_depthstencil_view *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d3d_depthstencil_view_init(object, device, resource, desc)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize depthstencil view, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created depthstencil view %p.\n", object);
|
|
|
|
*view = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-11-04 23:37:15 +01:00
|
|
|
struct d3d_depthstencil_view *unsafe_impl_from_ID3D11DepthStencilView(ID3D11DepthStencilView *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d11_depthstencil_view_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D11DepthStencilView(iface);
|
|
|
|
}
|
|
|
|
|
2015-09-08 01:12:41 +02:00
|
|
|
struct d3d_depthstencil_view *unsafe_impl_from_ID3D10DepthStencilView(ID3D10DepthStencilView *iface)
|
2014-08-22 12:32:03 +02:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d10_depthstencil_view_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D10DepthStencilView(iface);
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
/* ID3D11RenderTargetView methods */
|
|
|
|
|
|
|
|
static inline struct d3d_rendertarget_view *impl_from_ID3D11RenderTargetView(ID3D11RenderTargetView *iface)
|
2011-07-12 12:34:22 +02:00
|
|
|
{
|
2015-09-09 01:35:42 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_rendertarget_view, ID3D11RenderTargetView_iface);
|
2011-07-12 12:34:22 +02:00
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_rendertarget_view_QueryInterface(ID3D11RenderTargetView *iface,
|
2009-01-23 10:22:34 +01:00
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
2015-09-09 01:35:42 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_ID3D11RenderTargetView)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11View)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|
2009-01-23 10:22:34 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2015-09-09 01:35:42 +02:00
|
|
|
ID3D11RenderTargetView_AddRef(iface);
|
2009-01-23 10:22:34 +01:00
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D10RenderTargetView)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10View)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
|
|
|
|
{
|
|
|
|
ID3D10RenderTargetView_AddRef(&view->ID3D10RenderTargetView_iface);
|
|
|
|
*object = &view->ID3D10RenderTargetView_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
2009-01-23 10:22:34 +01:00
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_AddRef(ID3D11RenderTargetView *iface)
|
2009-01-23 10:22:34 +01:00
|
|
|
{
|
2015-09-09 01:35:42 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&view->refcount);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", view, refcount);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_Release(ID3D11RenderTargetView *iface)
|
2009-01-23 10:22:34 +01:00
|
|
|
{
|
2015-09-09 01:35:42 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&view->refcount);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", view, refcount);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-09 01:35:42 +02:00
|
|
|
wined3d_rendertarget_view_decref(view->wined3d_view);
|
2015-09-09 01:35:43 +02:00
|
|
|
ID3D11Resource_Release(view->resource);
|
2015-09-09 01:35:46 +02:00
|
|
|
ID3D11Device_Release(view->device);
|
2015-09-09 01:35:42 +02:00
|
|
|
wined3d_private_store_cleanup(&view->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2015-09-09 01:35:42 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, view);
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d11_rendertarget_view_GetDevice(ID3D11RenderTargetView *iface,
|
|
|
|
ID3D11Device **device)
|
|
|
|
{
|
2015-09-09 01:35:46 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
|
|
|
*device = view->device;
|
|
|
|
ID3D11Device_AddRef(*device);
|
2015-09-09 01:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_rendertarget_view_GetPrivateData(ID3D11RenderTargetView *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return d3d_get_private_data(&view->private_store, guid, data_size, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_rendertarget_view_SetPrivateData(ID3D11RenderTargetView *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return d3d_set_private_data(&view->private_store, guid, data_size, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_rendertarget_view_SetPrivateDataInterface(ID3D11RenderTargetView *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
|
|
|
return d3d_set_private_data_interface(&view->private_store, guid, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d11_rendertarget_view_GetResource(ID3D11RenderTargetView *iface,
|
|
|
|
ID3D11Resource **resource)
|
|
|
|
{
|
2015-09-09 01:35:43 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, resource %p.\n", iface, resource);
|
|
|
|
|
|
|
|
*resource = view->resource;
|
|
|
|
ID3D11Resource_AddRef(*resource);
|
2015-09-09 01:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d11_rendertarget_view_GetDesc(ID3D11RenderTargetView *iface,
|
|
|
|
D3D11_RENDER_TARGET_VIEW_DESC *desc)
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
|
|
|
*desc = view->desc;
|
2015-09-09 01:35:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID3D11RenderTargetViewVtbl d3d11_rendertarget_view_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d11_rendertarget_view_QueryInterface,
|
|
|
|
d3d11_rendertarget_view_AddRef,
|
|
|
|
d3d11_rendertarget_view_Release,
|
|
|
|
/* ID3D11DeviceChild methods */
|
|
|
|
d3d11_rendertarget_view_GetDevice,
|
|
|
|
d3d11_rendertarget_view_GetPrivateData,
|
|
|
|
d3d11_rendertarget_view_SetPrivateData,
|
|
|
|
d3d11_rendertarget_view_SetPrivateDataInterface,
|
|
|
|
/* ID3D11View methods */
|
|
|
|
d3d11_rendertarget_view_GetResource,
|
|
|
|
/* ID3D11RenderTargetView methods */
|
|
|
|
d3d11_rendertarget_view_GetDesc,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ID3D10RenderTargetView methods */
|
|
|
|
|
|
|
|
static inline struct d3d_rendertarget_view *impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d3d_rendertarget_view, ID3D10RenderTargetView_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_QueryInterface(ID3D10RenderTargetView *iface,
|
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return d3d11_rendertarget_view_QueryInterface(&view->ID3D11RenderTargetView_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_AddRef(ID3D10RenderTargetView *iface)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_rendertarget_view_AddRef(&view->ID3D11RenderTargetView_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTargetView *iface)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_rendertarget_view_Release(&view->ID3D11RenderTargetView_iface);
|
|
|
|
}
|
|
|
|
|
2009-01-23 10:22:34 +01:00
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDevice(ID3D10RenderTargetView *iface, ID3D10Device **device)
|
|
|
|
{
|
2015-09-09 01:35:41 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
2014-02-13 10:14:23 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
2015-09-09 01:35:46 +02:00
|
|
|
ID3D11Device_QueryInterface(view->device, &IID_ID3D10Device, (void **)device);
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-09-09 01:35:41 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
2015-03-12 10:08:36 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n",
|
2009-01-23 10:22:34 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_get_private_data(&view->private_store, guid, data_size, data);
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_SetPrivateData(ID3D10RenderTargetView *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-09-09 01:35:41 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
2015-03-12 10:08:34 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
|
2009-01-23 10:22:34 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data(&view->private_store, guid, data_size, data);
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_SetPrivateDataInterface(ID3D10RenderTargetView *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
2015-09-09 01:35:41 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
2015-03-12 10:08:35 +01:00
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data_interface(&view->private_store, guid, data);
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10View methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTargetView *iface,
|
|
|
|
ID3D10Resource **resource)
|
|
|
|
{
|
2015-09-09 01:35:41 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
2009-01-23 10:22:34 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, resource %p\n", iface, resource);
|
|
|
|
|
2015-09-09 01:35:43 +02:00
|
|
|
ID3D11Resource_QueryInterface(view->resource, &IID_ID3D10Resource, (void **)resource);
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10RenderTargetView methods */
|
|
|
|
|
2009-10-29 18:56:24 +01:00
|
|
|
static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView *iface,
|
2009-01-23 10:22:34 +01:00
|
|
|
D3D10_RENDER_TARGET_VIEW_DESC *desc)
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
struct d3d_rendertarget_view *view = impl_from_ID3D10RenderTargetView(iface);
|
2009-01-26 09:38:14 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, desc %p\n", iface, desc);
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
memcpy(desc, &view->desc, sizeof(*desc));
|
2009-01-23 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
2009-10-29 18:56:23 +01:00
|
|
|
static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
|
2009-01-23 10:22:34 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d10_rendertarget_view_QueryInterface,
|
|
|
|
d3d10_rendertarget_view_AddRef,
|
|
|
|
d3d10_rendertarget_view_Release,
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
d3d10_rendertarget_view_GetDevice,
|
|
|
|
d3d10_rendertarget_view_GetPrivateData,
|
|
|
|
d3d10_rendertarget_view_SetPrivateData,
|
|
|
|
d3d10_rendertarget_view_SetPrivateDataInterface,
|
|
|
|
/* ID3D10View methods */
|
|
|
|
d3d10_rendertarget_view_GetResource,
|
|
|
|
/* ID3D10RenderTargetView methods */
|
|
|
|
d3d10_rendertarget_view_GetDesc,
|
|
|
|
};
|
2009-10-29 18:56:23 +01:00
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarget_view_desc *wined3d_desc,
|
|
|
|
const D3D11_RENDER_TARGET_VIEW_DESC *desc)
|
2014-08-21 09:55:53 +02:00
|
|
|
{
|
|
|
|
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
|
|
|
|
|
|
|
|
switch (desc->ViewDimension)
|
|
|
|
{
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_BUFFER:
|
|
|
|
wined3d_desc->u.buffer.start_idx = desc->u.Buffer.u1.FirstElement;
|
|
|
|
wined3d_desc->u.buffer.count = desc->u.Buffer.u2.NumElements;
|
2014-08-21 09:55:53 +02:00
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE1D:
|
2014-08-21 09:55:53 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture1D.MipSlice;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE1DARRAY:
|
2014-08-21 09:55:53 +02:00
|
|
|
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;
|
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE2D:
|
2014-08-21 09:55:53 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture2D.MipSlice;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE2DARRAY:
|
2014-08-21 09:55:53 +02:00
|
|
|
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;
|
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE2DMS:
|
2014-08-21 09:55:53 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY:
|
2014-08-21 09:55:53 +02:00
|
|
|
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;
|
|
|
|
break;
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
case D3D11_RTV_DIMENSION_TEXTURE3D:
|
2014-08-21 09:55:53 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture3D.MipSlice;
|
|
|
|
wined3d_desc->u.texture.layer_idx = desc->u.Texture3D.FirstWSlice;
|
|
|
|
wined3d_desc->u.texture.layer_count = desc->u.Texture3D.WSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
|
|
|
|
wined3d_desc->u.texture.level_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:45 +02:00
|
|
|
static HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device,
|
2015-09-09 01:35:44 +02:00
|
|
|
ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc)
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2014-08-21 09:55:53 +02:00
|
|
|
struct wined3d_rendertarget_view_desc wined3d_desc;
|
2011-03-01 09:47:56 +01:00
|
|
|
struct wined3d_resource *wined3d_resource;
|
2009-10-29 18:56:23 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-09-09 01:35:42 +02:00
|
|
|
view->ID3D11RenderTargetView_iface.lpVtbl = &d3d11_rendertarget_view_vtbl;
|
2011-07-12 12:37:59 +02:00
|
|
|
view->ID3D10RenderTargetView_iface.lpVtbl = &d3d10_rendertarget_view_vtbl;
|
2009-10-29 18:56:23 +01:00
|
|
|
view->refcount = 1;
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
{
|
2016-05-18 00:04:38 +02:00
|
|
|
if (FAILED(hr = set_rtdesc_from_resource(&view->desc, resource)))
|
|
|
|
return hr;
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
view->desc = *desc;
|
2016-05-18 00:04:38 +02:00
|
|
|
normalize_rtv_desc(&view->desc, resource);
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
|
|
|
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-09 01:35:43 +02:00
|
|
|
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2015-09-09 01:35:43 +02:00
|
|
|
ERR("Failed to get wined3d resource for d3d11 resource %p.\n", resource);
|
2009-10-29 18:56:23 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:44 +02:00
|
|
|
wined3d_rendertarget_view_desc_from_d3d11(&wined3d_desc, &view->desc);
|
2014-08-21 09:55:55 +02:00
|
|
|
if (FAILED(hr = wined3d_rendertarget_view_create(&wined3d_desc, wined3d_resource,
|
2015-10-09 03:19:12 +02:00
|
|
|
view, &d3d_null_wined3d_parent_ops, &view->wined3d_view)))
|
2009-10-29 18:56:23 +01:00
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-10-29 18:56:23 +01:00
|
|
|
WARN("Failed to create a wined3d rendertarget view, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-03-12 10:08:34 +01:00
|
|
|
wined3d_private_store_init(&view->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2012-09-08 11:26:23 +02:00
|
|
|
view->resource = resource;
|
2015-09-09 01:35:43 +02:00
|
|
|
ID3D11Resource_AddRef(resource);
|
2015-09-09 01:35:46 +02:00
|
|
|
view->device = &device->ID3D11Device_iface;
|
|
|
|
ID3D11Device_AddRef(view->device);
|
2012-09-08 11:26:23 +02:00
|
|
|
|
2009-10-29 18:56:23 +01:00
|
|
|
return S_OK;
|
2011-07-12 12:34:22 +02:00
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:45 +02:00
|
|
|
HRESULT d3d_rendertarget_view_create(struct d3d_device *device, ID3D11Resource *resource,
|
|
|
|
const D3D11_RENDER_TARGET_VIEW_DESC *desc, struct d3d_rendertarget_view **view)
|
|
|
|
{
|
|
|
|
struct d3d_rendertarget_view *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d3d_rendertarget_view_init(object, device, resource, desc)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize rendertarget view, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created rendertarget view %p.\n", object);
|
|
|
|
*view = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-14 02:08:15 +02:00
|
|
|
struct d3d_rendertarget_view *unsafe_impl_from_ID3D11RenderTargetView(ID3D11RenderTargetView *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d11_rendertarget_view_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D11RenderTargetView(iface);
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:35:41 +02:00
|
|
|
struct d3d_rendertarget_view *unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface)
|
2011-07-12 12:34:22 +02:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d10_rendertarget_view_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D10RenderTargetView(iface);
|
2009-10-29 18:56:23 +01:00
|
|
|
}
|
2009-10-30 20:11:33 +01:00
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
/* ID3D11ShaderResourceView methods */
|
|
|
|
|
2015-10-26 19:20:51 +01:00
|
|
|
static inline struct d3d_shader_resource_view *impl_from_ID3D11ShaderResourceView(ID3D11ShaderResourceView *iface)
|
2011-06-01 10:46:00 +02:00
|
|
|
{
|
2015-09-10 00:55:43 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_shader_resource_view, ID3D11ShaderResourceView_iface);
|
2011-06-01 10:46:00 +02:00
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_shader_resource_view_QueryInterface(ID3D11ShaderResourceView *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
2015-09-10 00:55:43 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
2009-10-30 20:11:33 +01:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D11ShaderResourceView)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11View)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|
2009-10-30 20:11:33 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2015-09-10 00:55:43 +02:00
|
|
|
ID3D11ShaderResourceView_AddRef(iface);
|
2009-10-30 20:11:33 +01:00
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D10ShaderResourceView1)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10ShaderResourceView)
|
2015-09-10 00:55:43 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10View)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
|
|
|
|
{
|
2015-10-19 01:41:58 +02:00
|
|
|
ID3D10ShaderResourceView1_AddRef(&view->ID3D10ShaderResourceView1_iface);
|
|
|
|
*object = &view->ID3D10ShaderResourceView1_iface;
|
2015-09-10 00:55:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-30 20:11:33 +01:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_AddRef(ID3D11ShaderResourceView *iface)
|
2009-10-30 20:11:33 +01:00
|
|
|
{
|
2015-09-10 00:55:43 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&view->refcount);
|
2009-10-30 20:11:33 +01:00
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", view, refcount);
|
2009-10-30 20:11:33 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_Release(ID3D11ShaderResourceView *iface)
|
2009-10-30 20:11:33 +01:00
|
|
|
{
|
2015-09-10 00:55:43 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&view->refcount);
|
2009-10-30 20:11:33 +01:00
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", view, refcount);
|
2009-10-30 20:11:33 +01:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-10 00:55:43 +02:00
|
|
|
wined3d_shader_resource_view_decref(view->wined3d_view);
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Resource_Release(view->resource);
|
2015-09-10 00:55:44 +02:00
|
|
|
ID3D11Device_Release(view->device);
|
2015-09-10 00:55:43 +02:00
|
|
|
wined3d_private_store_cleanup(&view->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2015-09-10 00:55:43 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, view);
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d11_shader_resource_view_GetDevice(ID3D11ShaderResourceView *iface,
|
|
|
|
ID3D11Device **device)
|
|
|
|
{
|
2015-09-10 00:55:44 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
|
|
|
*device = view->device;
|
|
|
|
ID3D11Device_AddRef(*device);
|
2015-09-10 00:55:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_shader_resource_view_GetPrivateData(ID3D11ShaderResourceView *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return d3d_get_private_data(&view->private_store, guid, data_size, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_shader_resource_view_SetPrivateData(ID3D11ShaderResourceView *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return d3d_set_private_data(&view->private_store, guid, data_size, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_shader_resource_view_SetPrivateDataInterface(ID3D11ShaderResourceView *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
|
|
|
return d3d_set_private_data_interface(&view->private_store, guid, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d11_shader_resource_view_GetResource(ID3D11ShaderResourceView *iface,
|
|
|
|
ID3D11Resource **resource)
|
|
|
|
{
|
2015-09-10 00:55:46 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, resource %p.\n", iface, resource);
|
|
|
|
|
|
|
|
*resource = view->resource;
|
|
|
|
ID3D11Resource_AddRef(*resource);
|
2015-09-10 00:55:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d11_shader_resource_view_GetDesc(ID3D11ShaderResourceView *iface,
|
|
|
|
D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
|
|
|
|
{
|
2015-09-10 00:55:45 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
|
|
|
*desc = view->desc;
|
2015-09-10 00:55:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID3D11ShaderResourceViewVtbl d3d11_shader_resource_view_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d11_shader_resource_view_QueryInterface,
|
|
|
|
d3d11_shader_resource_view_AddRef,
|
|
|
|
d3d11_shader_resource_view_Release,
|
|
|
|
/* ID3D11DeviceChild methods */
|
|
|
|
d3d11_shader_resource_view_GetDevice,
|
|
|
|
d3d11_shader_resource_view_GetPrivateData,
|
|
|
|
d3d11_shader_resource_view_SetPrivateData,
|
|
|
|
d3d11_shader_resource_view_SetPrivateDataInterface,
|
|
|
|
/* ID3D11View methods */
|
|
|
|
d3d11_shader_resource_view_GetResource,
|
|
|
|
/* ID3D11ShaderResourceView methods */
|
|
|
|
d3d11_shader_resource_view_GetDesc,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ID3D10ShaderResourceView methods */
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static inline struct d3d_shader_resource_view *impl_from_ID3D10ShaderResourceView(ID3D10ShaderResourceView1 *iface)
|
2015-09-10 00:55:43 +02:00
|
|
|
{
|
2015-10-19 01:41:58 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_shader_resource_view, ID3D10ShaderResourceView1_iface);
|
2015-09-10 00:55:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_QueryInterface(ID3D10ShaderResourceView1 *iface,
|
2015-09-10 00:55:43 +02:00
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return d3d11_shader_resource_view_QueryInterface(&view->ID3D11ShaderResourceView_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_shader_resource_view_AddRef(ID3D10ShaderResourceView1 *iface)
|
2015-09-10 00:55:43 +02:00
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_shader_resource_view_AddRef(&view->ID3D11ShaderResourceView_iface);
|
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_shader_resource_view_Release(ID3D10ShaderResourceView1 *iface)
|
2015-09-10 00:55:43 +02:00
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_shader_resource_view_Release(&view->ID3D11ShaderResourceView_iface);
|
|
|
|
}
|
|
|
|
|
2009-10-30 20:11:33 +01:00
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDevice(ID3D10ShaderResourceView1 *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
ID3D10Device **device)
|
|
|
|
{
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
2014-02-13 10:14:24 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
2015-09-10 00:55:44 +02:00
|
|
|
ID3D11Device_QueryInterface(view->device, &IID_ID3D10Device, (void **)device);
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView1 *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
2015-03-13 09:49:26 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n",
|
2009-10-30 20:11:33 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_get_private_data(&view->private_store, guid, data_size, data);
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_SetPrivateData(ID3D10ShaderResourceView1 *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
2015-03-13 09:49:24 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
|
2009-10-30 20:11:33 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data(&view->private_store, guid, data_size, data);
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_SetPrivateDataInterface(ID3D10ShaderResourceView1 *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
2009-10-30 20:11:33 +01:00
|
|
|
|
2015-03-13 09:49:25 +01:00
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data_interface(&view->private_store, guid, data);
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10View methods */
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetResource(ID3D10ShaderResourceView1 *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
ID3D10Resource **resource)
|
|
|
|
{
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
2012-09-12 11:30:51 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, resource %p.\n", iface, resource);
|
|
|
|
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Resource_QueryInterface(view->resource, &IID_ID3D10Resource, (void **)resource);
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10ShaderResourceView methods */
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDesc(ID3D10ShaderResourceView1 *iface,
|
2009-10-30 20:11:33 +01:00
|
|
|
D3D10_SHADER_RESOURCE_VIEW_DESC *desc)
|
|
|
|
{
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
2012-09-14 13:11:31 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
2015-09-10 00:55:45 +02:00
|
|
|
memcpy(desc, &view->desc, sizeof(*desc));
|
2009-10-30 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
2015-10-19 01:41:58 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDesc1(ID3D10ShaderResourceView1 *iface,
|
|
|
|
D3D10_SHADER_RESOURCE_VIEW_DESC1 *desc)
|
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
|
|
|
memcpy(desc, &view->desc, sizeof(*desc));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID3D10ShaderResourceView1Vtbl d3d10_shader_resource_view_vtbl =
|
2009-10-30 20:11:33 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d10_shader_resource_view_QueryInterface,
|
|
|
|
d3d10_shader_resource_view_AddRef,
|
|
|
|
d3d10_shader_resource_view_Release,
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
d3d10_shader_resource_view_GetDevice,
|
|
|
|
d3d10_shader_resource_view_GetPrivateData,
|
|
|
|
d3d10_shader_resource_view_SetPrivateData,
|
|
|
|
d3d10_shader_resource_view_SetPrivateDataInterface,
|
|
|
|
/* ID3D10View methods */
|
|
|
|
d3d10_shader_resource_view_GetResource,
|
|
|
|
/* ID3D10ShaderResourceView methods */
|
|
|
|
d3d10_shader_resource_view_GetDesc,
|
2015-10-19 01:41:58 +02:00
|
|
|
/* ID3D10ShaderResourceView1 methods */
|
|
|
|
d3d10_shader_resource_view_GetDesc1,
|
2009-10-30 20:11:33 +01:00
|
|
|
};
|
|
|
|
|
2016-06-06 11:39:02 +02:00
|
|
|
static HRESULT wined3d_shader_resource_view_desc_from_d3d11(struct wined3d_shader_resource_view_desc *wined3d_desc,
|
|
|
|
const D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
|
|
|
|
{
|
|
|
|
wined3d_desc->format_id = wined3dformat_from_dxgi_format(desc->Format);
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = 0;
|
2016-06-06 11:39:02 +02:00
|
|
|
|
|
|
|
switch (desc->ViewDimension)
|
|
|
|
{
|
|
|
|
case D3D11_SRV_DIMENSION_BUFFER:
|
|
|
|
wined3d_desc->u.buffer.start_idx = desc->u.Buffer.u1.FirstElement;
|
|
|
|
wined3d_desc->u.buffer.count = desc->u.Buffer.u2.NumElements;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE1D:
|
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture1D.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.Texture1D.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE1DARRAY:
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
|
2016-06-06 11:39:02 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture1DArray.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.Texture1DArray.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = desc->u.Texture1DArray.FirstArraySlice;
|
|
|
|
wined3d_desc->u.texture.layer_count = desc->u.Texture1DArray.ArraySize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE2D:
|
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture2D.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.Texture2D.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE2DARRAY:
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
|
2016-06-06 11:39:02 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture2DArray.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.Texture2DArray.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
|
|
|
|
wined3d_desc->u.texture.layer_count = desc->u.Texture2DArray.ArraySize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE2DMS:
|
|
|
|
wined3d_desc->u.texture.level_idx = 0;
|
|
|
|
wined3d_desc->u.texture.level_count = 1;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY:
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_ARRAY;
|
2016-06-06 11:39:02 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = 0;
|
|
|
|
wined3d_desc->u.texture.level_count = 1;
|
|
|
|
wined3d_desc->u.texture.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
|
|
|
|
wined3d_desc->u.texture.layer_count = desc->u.Texture2DMSArray.ArraySize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURE3D:
|
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.Texture3D.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.Texture3D.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURECUBE:
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_CUBE;
|
2016-06-06 11:39:02 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.TextureCube.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.TextureCube.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = 0;
|
|
|
|
wined3d_desc->u.texture.layer_count = 6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_TEXTURECUBEARRAY:
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = WINED3D_VIEW_TEXTURE_CUBE | WINED3D_VIEW_TEXTURE_ARRAY;
|
2016-06-06 11:39:02 +02:00
|
|
|
wined3d_desc->u.texture.level_idx = desc->u.TextureCubeArray.MostDetailedMip;
|
|
|
|
wined3d_desc->u.texture.level_count = desc->u.TextureCubeArray.MipLevels;
|
|
|
|
wined3d_desc->u.texture.layer_idx = desc->u.TextureCubeArray.First2DArrayFace;
|
|
|
|
wined3d_desc->u.texture.layer_count = 6 * desc->u.TextureCubeArray.NumCubes;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3D11_SRV_DIMENSION_BUFFEREX:
|
2016-06-07 13:24:36 +02:00
|
|
|
wined3d_desc->flags = desc->u.BufferEx.Flags;
|
2016-06-06 11:39:02 +02:00
|
|
|
wined3d_desc->u.buffer.start_idx = desc->u.BufferEx.FirstElement;
|
|
|
|
wined3d_desc->u.buffer.count = desc->u.BufferEx.NumElements;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("Unrecognized view dimension %#x.\n", desc->ViewDimension);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:47 +02:00
|
|
|
static HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *view, struct d3d_device *device,
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
|
2009-10-30 20:11:33 +01:00
|
|
|
{
|
2016-06-06 11:39:02 +02:00
|
|
|
struct wined3d_shader_resource_view_desc wined3d_desc;
|
2014-12-01 08:45:43 +01:00
|
|
|
struct wined3d_resource *wined3d_resource;
|
2012-09-14 13:11:31 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-09-10 00:55:43 +02:00
|
|
|
view->ID3D11ShaderResourceView_iface.lpVtbl = &d3d11_shader_resource_view_vtbl;
|
2015-10-19 01:41:58 +02:00
|
|
|
view->ID3D10ShaderResourceView1_iface.lpVtbl = &d3d10_shader_resource_view_vtbl;
|
2009-10-30 20:11:33 +01:00
|
|
|
view->refcount = 1;
|
|
|
|
|
2012-09-14 13:11:31 +02:00
|
|
|
if (!desc)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = set_srdesc_from_resource(&view->desc, resource)))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
view->desc = *desc;
|
2016-05-18 00:04:38 +02:00
|
|
|
normalize_srv_desc(&view->desc, resource);
|
2012-09-14 13:11:31 +02:00
|
|
|
}
|
|
|
|
|
2016-06-06 11:39:02 +02:00
|
|
|
if (FAILED(hr = wined3d_shader_resource_view_desc_from_d3d11(&wined3d_desc, &view->desc)))
|
|
|
|
return hr;
|
|
|
|
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-10 00:55:46 +02:00
|
|
|
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
|
2014-12-01 08:45:43 +01:00
|
|
|
{
|
2016-03-25 14:26:22 +01:00
|
|
|
wined3d_mutex_unlock();
|
2016-05-18 00:04:38 +02:00
|
|
|
ERR("Failed to get wined3d resource for d3d11 resource %p.\n", resource);
|
2014-12-01 08:45:43 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2016-06-06 11:39:02 +02:00
|
|
|
if (FAILED(hr = wined3d_shader_resource_view_create(&wined3d_desc, wined3d_resource,
|
2015-10-09 03:19:12 +02:00
|
|
|
view, &d3d_null_wined3d_parent_ops, &view->wined3d_view)))
|
2014-09-16 10:44:15 +02:00
|
|
|
{
|
2016-03-25 14:26:22 +01:00
|
|
|
wined3d_mutex_unlock();
|
2014-09-16 10:44:15 +02:00
|
|
|
WARN("Failed to create wined3d shader resource view, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-03-13 09:49:24 +01:00
|
|
|
wined3d_private_store_init(&view->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2012-09-12 11:30:51 +02:00
|
|
|
view->resource = resource;
|
2015-09-10 00:55:46 +02:00
|
|
|
ID3D11Resource_AddRef(resource);
|
2015-09-10 00:55:44 +02:00
|
|
|
view->device = &device->ID3D11Device_iface;
|
|
|
|
ID3D11Device_AddRef(view->device);
|
2012-09-12 11:30:51 +02:00
|
|
|
|
2009-10-30 20:11:33 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2014-09-16 10:44:16 +02:00
|
|
|
|
2015-09-10 00:55:47 +02:00
|
|
|
HRESULT d3d_shader_resource_view_create(struct d3d_device *device, ID3D11Resource *resource,
|
|
|
|
const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, struct d3d_shader_resource_view **view)
|
|
|
|
{
|
|
|
|
struct d3d_shader_resource_view *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d3d_shader_resource_view_init(object, device, resource, desc)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created shader resource view %p.\n", object);
|
|
|
|
*view = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-11-06 18:38:11 +01:00
|
|
|
struct d3d_shader_resource_view *unsafe_impl_from_ID3D11ShaderResourceView(ID3D11ShaderResourceView *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d11_shader_resource_view_vtbl);
|
|
|
|
return impl_from_ID3D11ShaderResourceView(iface);
|
|
|
|
}
|
|
|
|
|
2015-09-10 00:55:42 +02:00
|
|
|
struct d3d_shader_resource_view *unsafe_impl_from_ID3D10ShaderResourceView(ID3D10ShaderResourceView *iface)
|
2014-09-16 10:44:16 +02:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
2015-10-19 01:41:58 +02:00
|
|
|
assert(iface->lpVtbl == (ID3D10ShaderResourceViewVtbl *)&d3d10_shader_resource_view_vtbl);
|
|
|
|
return CONTAINING_RECORD(iface, struct d3d_shader_resource_view, ID3D10ShaderResourceView1_iface);
|
2014-09-16 10:44:16 +02:00
|
|
|
}
|